2
为什么GetInterfaces()在下面的代码返回具有全名= NULL接口类型谁能给我解释一下?GetInterfaces()返回全名= NULL泛型接口类型,
public class Program
{
static void Main(string[] args)
{
Type[] interfaces = typeof (Data<>).GetInterfaces();
foreach (Type @interface in interfaces)
{
Console.WriteLine("Name='{0}' FullName='{1}'", @interface.Name, @interface.FullName ?? "null");
}
}
}
public class Data<T> : IData<T>
{
public T Content { get; set; }
}
public interface IData<T>
{
T Content { get; set; }
}
程序的输出是:
Name=IData`1' FullName='null'
我有点期待:
Name=IData`1'
FullName='ConsoleApplication2.IData`1'
请赐教:)
直链接到外部网站可能提供答案,但提供从链路固有风险所以。如果链接变得无效,404会被编辑等等会发生什么。问题的答案会丢失。在答案中提供解释并提供支持答案的链接是有帮助的,这将是非常有益的。这遵循一般的SO指导原则。 – Hooligancat 2017-06-16 10:43:29
@Hooligancat我从文档加和示例中添加了一个小引用。 – 2017-08-01 10:01:30