【.net core】通过类名字符串获取类成员

// 从当前执行的程序集获取
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);

你可能感兴趣的:(.netcore,java,开发语言)