在.NET Framework中存在这样的方法:
public ConstructorInfo GetConstructor(
BindingFlags bindingAttr,
Binder binder,
CallingConventions callConvention,
Type[] types,
ParameterModifier[] modifiers
)
但在.NET Core(1.1)中,我只找到了一个扩展,它没有给我私有构造函数:
public static ConstructorInfo GetConstructor(this Type type, Type[] types)
所以我想知道在.NET Core中是否有办法访问和获取私有构造函数。
GetTypeInfo().DeclaredConstructors
和 LINQ 过滤器来查找所需的构造函数。 - Ivan StoevTypeInfo
类。自 .NET Core 2.0 以来,该经典 API 调用已被实现。 - thehennyy