I'm trying to upgrade my .NET 4 project to .NETStandard and Core, but unable to find the equivalent for this:-
var ctors = typeof(T).GetConstructors();
GetConstructors is a part of reflection, so seems like the support is intentionally lacking or moving...
Thanks. Simon.
In .NET standard /Core a lot of reflexion api are moved to a specific package (system.reflection). This package provide the extension method GetTypeInfo
on Type class.
typeof(T).GetTypeInfo().DeclaredConstructors;
It's easy - just add GetTypeInfo()
:
var ctors = typeof(T).GetTypeInfo().DeclaredConstructors();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With