Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

how do i get the generic type?

$
0
0

hi

lets say i have

var someValue = List<SomeClass>(); //SomeClass inherits from BaseClass

i want to get what type is in the list (eg SomeClass) and then find if it inherits from baseclass

this is what i have but its not working

PropertyInfo prop;

if(prop.PropertyType.GetGenericTypeDefinition().IsSubclassOf(typeof(BaseClass))

but GetGenericTypeDefinition doesn't do what i thought, and googling is getting me no where fast.

Any thoughts would e appriciated.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>