© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
46 replies
the doctor monster

❔ Use Variable as Type

Hiya 🙂
I'm needing some help with a WinForms Project. I want to take an object from a list and convert that object's properties to an array. The object type, however, can vary. I have a form that asks for what type the user wants, and I want to pass that decision into my code as a variable so that the correct object type is loaded. I've been using dynamic, but it mistakes one class for another, and dynamic is ugly anyway. Attached the code for that bit with dynamic in. Thanks!
image.png
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

Similar Threads

❔ Pass variable type as class parameter
C#CC# / help
3y ago
Variable type passed to generic
C#CC# / help
2y ago
cannot convert from 'TypeA' to 'TypeB' with generics
C#CC# / help
2y ago