// 从当前执行的程序集获取
Assembly assembly = Assembly.GetExecutingAssembly();
Type type = assembly.GetType("YourNamespace.YourClass");
// 或从指定程序集获取
Assembly assembly = Assembly.Load("YourAssemblyName");
Type type = assembly.GetType("YourNamespace.YourClass");
// 获取所有公共实例属性
PropertyInfo[] publicFields = type.GetFields();
// 获取所有属性(包括私有、受保护的实例和静态字段)
PropertyInfo[] publicFields = type.GetProperties(BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.Static);
【.net core】通过类名字符串获取类成员
于 2025-06-10 09:18:45 首次发布