有没有办法获取接口成员列表?我了解 System.Reflection.MemberInfo,但它包括对象中的所有内容,而不仅仅是某个接口。
这是程序,我不知道如何获得接口,因为它不是我写的,但它是 Ascom 标准的一部分(http://ascom-standards.org).
public static void Test1()
{
Console.WriteLine("mark1"); // this shows up...
var type = typeof(Ascom.Interface.ITelescope);
var members = type.GetMembers();
Console.WriteLine(members.Count); // gives 0
foreach (var member in members)
{
Console.WriteLine(member.Name); //nothing from here
}
Console.WriteLine("mark4"); // ...as well as this
}
来自 MSDN:
typeof(IList).GetMembers()
获取当前 Type 的成员(属性、方法、字段、事件等)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)