public class TestBase
{
// implementation
}
public class Test : ICollection<TestBase>
{
// implementation
}
Somewhere else I have a property of the Test type:
public Test Test {get;set;}
How can I get the underlying type of the ICollection that the Test inherits from?
What you are probably looking for is GetGenericArguments()
.
var type = typeof(Test);
var collInterface = type.GetInterfaces()[0];
var generic = collInterface.GetGenericArguments()[0];