WDTBD: Linq Cast

Linq supplies a Cast option. It can be used in case you have a list with object A that must be converted to a list of object B, where object B inherits of object A. You don’t have to write a foreach or map objects anymore. Advertisements

Compare, in case, not sensitive

This does the same, but the second improved my performance (ok, not mine, but the performance of my application). foreach (var track in tracks .Where(track => track.Name.ToLower() == fileName.ToLower())) “Upper-casing both strings is silly, because you create two new strings and then still perform a case-sensitive search.”source foreach (var track in tracks .Where(track => string.Equals(track.Name, fileName, StringComparison.OrdinalIgnoreCase)))