为什么typeof(t).GetProperties()在t是派生接口时没有找到t的所有公共属性?这是预期的行为还是我遗失了什么?
public interface IBaseOne
{ int Id { get; } }
public interface IDerivedOne : IBaseOne
{ string Name { get; } }
public class ImplementsIDerivedOne : IDerivedOne
{
public int Id { get; private set; }
public string Name { get; private set; }
}
public static class TypeOfTests
{
public static Type Testing<T>() where T : class,IBaseOne
{
return typeof(T);
}
}
class Program
{
static void Main(string[] args)
{
Type typeFromIBaseOne = TypeOfTests.Testing<IBaseOne >() ;
Type typeFromIDerivedOne …Run Code Online (Sandbox Code Playgroud)