© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
95 replies
memw

❔ Reflections and generics

So i have a type instance list and i'm iterating trough all the fields that the propertyType.Name.Contains("ExtensionConfig"), that type has a method which i need to invoke foreach field and i'm iterating trough the fields

So basically the problem comes when i do
(field as PropertyInfo).GetValue(type)
(field as PropertyInfo).GetValue(type)
shows invalid cast exception, and i can't cast because the target type has a generic type which in every field is different
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ Enum and generics
C#CC# / help
3y ago
❔ Generics and nullable types
C#CC# / help
3y ago
Generics and type inference
C#CC# / help
4y ago
❔ Generics
C#CC# / help
3y ago