Copying a List to List

List<DerivedClass> result = 
    listBaseClass.ConvertAll(instance => (DerivedClass)instance);

Actually ConvertAll is good when you need to create new objects based on the original, when you just need to cast you can use the following

List<DerivedClass> result = 
    listBaseClass.Cast<DerivedClass>().ToList();

If not all of the items in your list can be cast to DerivedClass then use OfType instead

List<DerivedClass> result =
    listBaseClass.OfType<DerivedClass>().ToList();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)