In C#, what is the best way to access a property of the derived class when the generic list contains just the base class.
public class ClassA : BaseClass {
Further to TimJ's answer, you can write one extension method that will work for all types:
public static IEnumerable<T> OfType<T>(this IEnumerable list) { foreach (var obj in list) { if (obj is T) yield return (T)obj; } }
Or if you have Linq, that function is in the namespace System.Linq.