using System.Collections.Generic;
public static void Main()
List<SomeBaseType> list = [new SomeSubType(),
new SomeSubTypeWP(){SomeProperty="One"},
new SomeSubTypeWP(){SomeProperty="Two"},
new SomeSubTypeWP(){SomeProperty="Three"}
list.OfType<IHasSomeProperty>().Print();
public interface IHasSomeProperty
string SomeProperty {get; set;}
public abstract class SomeBaseType
public sealed class SomeSubType : SomeBaseType
public sealed class SomeSubTypeWP : SomeBaseType, IHasSomeProperty
public string SomeProperty {get; set;}
public static class ListOfTypesWithSomePropertyExtensions
public static void Print(this IEnumerable<IHasSomeProperty> list)
foreach(var item in list) Console.WriteLine(item.SomeProperty);