Код: Выделить всё
public interface A
{
public T Property { get; }
}
public class BaseClass : A, A
{
string A.Property => "BaseClass";
int A.Property => 0;
}
public class DerivedClass : BaseClass, A, A
{
string A.Property => "DerivedClass";
int A.Property => 1;
}
[Fact]
public async Task Test1()
{
var obj = new DerivedClass();
var values = obj.GetType().GetInterfaces().Where(i => i.GetGenericTypeDefinition() == typeof(A)).Select(i => i.GetProperty(nameof(A.Property))!.GetValue(obj)!);
Assert.Equal(4, values.Count());
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... g-for-base