Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4380744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:34:08+00:00 2026-05-21T12:34:08+00:00

i have a base Question class and lot of classes that derives from this

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:34:08+00:00Added an answer on May 21, 2026 at 12:34 pm

    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 use Activator.CreateInstance() to create an instance of that type.

    string xmlTagName = "RadioButtonQuestion";
    Type type = Type.GetType("Test." + xmlTagName );
    var question = Activator.CreateInstance(type);
    

    Also keep in mind that Activator.CreateInstance() returns object. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the question is simple. I have a base abstract class (person). From this i
I have a question, here are two classes below: class Base{ public: virtual void
This is more of a conceptual question than anything. I have a base class
basic c++ question i'm fairly sure. if i have a base class with a
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC
In the project I'm working on now, we have base Entity class that looks
I have a base class ( car ) and a class that inherit the
I have two tables. With Sqlalchemy, I map them to two classes: class A(base):
Okay, so we have a utility here in-house that generates business-model classes from our
I have a base class that has an enum value that I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.