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

  • Home
  • SEARCH
  • 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 8298015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:37:00+00:00 2026-06-08T15:37:00+00:00

Say you have the collection of key/value pair. for e.g. : – dictionary<string,string> myObjectToBeCreated

  • 0

Say you have the collection of key/value pair. for e.g. : –

dictionary<string,string> myObjectToBeCreated = new dictionary<string,string>();
myObjectToBeCreated.Add("int","myIntObject");
myObjectToBeCreated.Add("string","myStringObject");
myObjectToBeCreated.Add("employee","myEmployeeObject");

Now, How can you create the object of int named myIntObject using myObjectToBeCreated. something like this: –

int myIntObject;
string myStringObject;
Employee myEmployeeObject = new Employee();

Note: You have just the collection. This collection is having the dataTypes and objectnames. How can you create the object of those dataType with the specific names(defined in dictionary). You can pass this collection (MyObjectsToBeCreated in any method you want to). But at the end you should get the object of type (specified in dictionary).

You can use any design pattern say factory/dependency/builder. Or even you are free to achieve the above w/o using pattern.

  • 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-06-08T15:37:01+00:00Added an answer on June 8, 2026 at 3:37 pm

    Using just the class name for custom class won’t be enough. You need the whole namespace.

    Then assuming you have a parameterless constructor for your type you can use

    Activator.CreateInstance(Type.GetType(strNamespace + strType))
    

    or

    Activator.CreateInstance(strNamespace, strType)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Save that I have a (large) collection of instances of Dictionary. The key value
Say I have a collection of bytes var bytes = new byte[] {0, 1,
Let's say we have a collection of Person objects class Person { public string
I have a Dictionary<int, string> cached (for 20 minutes) that has ~120 ID/Name pairs
Lets say I have collection of documents with specified longitude and latitude. type is
Lets say I have a collection of blocks. 12 are red, 8 are blue,
So say I have a collection of Bloops Class Bloop Public FirstName Public LastName
Let's say I have a collection of 'items' like so: <p class=item>Item 1</p> <p
Let's say I have a collection of objects which can be sorted using a
Let's say I have a collection like: $products = Mage::getModel('catalog/product') ->getCollection() ... ->load(); How

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.