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.
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
or