i have a base Question class and lot of classes that derives from this class like CheckboxQuestion class and RadioButtonQuestion class
the program iterates over xml code for every block that is inside a question tag it will make a new element based on the tag’s name and is a child class of the Question class
<question number="1">
<RadioButtonQuestion>
<title>What is the right ...</title>
<choices>
<choice value="1">answer 1</choice>
<choice value="2">answer 2</choice>
<choice value="3">answer 3</choice>
<choice value="4">answer 4</choice>
</choices>
</RadioButtonQuestion>
</question>
after iterating on all the xml file i want to put all the questions in IEnumerable<Questions> the problem is that i don’t know how to make a new class based on the text written in an xml document
If the XML tag directly reflects the name of your class you can use
Type.GetType()to determine the corresponding type – keep in mind that it needs the full namespace though (“Test” in the example below). Then you can useActivator.CreateInstance()to create an instance of that type.Also keep in mind that
Activator.CreateInstance()returnsobject. It might be better overall if you determined the right type depending on the tag name, and then instantiated an instance the old fashioned way.