更新时间:2023-11-10 19:21:22
是的,请使用反射:
foreach (Type type in assembly.GetTypes())
{
foreach (MethodInfo method in type.GetMethods(BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
{
Console.WriteLine("{0} {1}{2}.{3}", GetFriendlyAccess(method),
method.IsStatic ? "static " : "", type.Name, method.Name);
}
}
我将把GetFriendlyAccessName留给读者作为练习-使用IsFamily,IsPrivate,IsPublic,IsProtected等-或Attributes属性.
I'll leave GetFriendlyAccessName as an exercise to the reader - use IsFamily, IsPrivate, IsPublic, IsProtected etc - or the Attributes property.