I having some problem in checking the type of my variable when it is generic.
Example T
is List<MyClass>
T is List<MyClass>
//return false
T is List
//return false
In the end, I have to use some stupid method in order to get the correct answer
T.toString() == "List<MyClass>"
//return true
Is there any standard way to deal with it, or I need to stick with my stupid method until official release?
I made the "T is SomeClass" mistake before. T is a class so the "is" won't work on it.
On elements you should use T == MyClass
.
On lists you should instantiate a List e.g. List<MyClass>() is T
.
This is not a clean solution but List<MyClass> == T
and List<MyClass>() == T
won't work. Unfortunatly until now I did not figure out any better solution. Hope it works.
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