あなたのクラスAがこれに似ているとしましょう。
abstract class A
{
public string PropertyA { get; set; }
public abstract List<PropertyInfo> Foo();
}
クラスBがこのクラスから継承し、Foo()メソッドをオーバーライドすると、次の定義のようになります。
abstract class B : A
{
public string PropertyB { get; set; }
public override List<PropertyInfo> Foo()
{
return GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
.ToList();
}
}
また、最後のクラス、つまり唯一の具体的なクラスであるCは、次のように単純に定義されます。
class C : B
{
public string PropertyC { get; set; }
}
このソリューションをテストし、返されるプロパティがPropertyCだけであることを確認するには、次のコード行を実行する必要があります。
class Program
{
static void Main()
{
new C().Foo().ForEach(x => Console.WriteLine(x.Name));
Console.Read();
}
}