In .Net we have Type.IsClass
to check if a type is a class using System.Reflection
.
But in .Net Core no. So, how can I check?
Try calling GetTypeInfo()
to get at this information.
This is ok, on: .net Core 1.1
using System.Reflection;
bool isClass = obj.GetType().GetTypeInfo().IsClass;
In .NET Core 2.2 you can do:
bool isClass = obj.GetType().IsClass;
The following will no longer work:
bool isClass = obj.GetTypeInfo().IsClass;
bool isClass = obj.GetType().GetTypeInfo().IsClass;
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