© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
55 replies
Oombuu

Get Object of unknown type with unknown parameters from string

I have an abstract parent class with several child classes, each child class has an export method that returns a string that hold the data of the instance of the subclass in the form of:
[SUBCLASS_NAME] | [PARAM#1] | [PARAM#2] | [PARAM#3]...
and so on for all of the parameters, these parameters can be Enum values (The Enums are located in the parent class), strings, integers, and possibly in the future, doubles / floats.
I want to write a static method in the parent class that will return an instance of the child class defined at the beginning of the input string, that will then use the remaining data in the string as parameters.
Currently I lack the understanding of types as well as the GetConstructor method, and also the understanding to assemble the type list properly, I've read the official documentation but it was a little too complex to grasp, could somebody help me figure out how to achieve this?
Attached is my current attempt.
Screenshot_2024-08-07_203208.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
Next page

Similar Threads

✅ Unable to cast object of type 'System.String' to type 'System.Int32'.
C#CC# / help
2y ago
✅ Convert from string to Type?
C#CC# / help
3y ago
❔ Get property from type
C#CC# / help
3y ago
Sorthing house numbers of type string
C#CC# / help
14mo ago