I have a requirement where the object type [name of the object] is passed as a string variable. Now based on the object name passed, I need to create that object type. Please note the string value contains the exact object type name. I have written a code snippet but it is throwing an exception.
e.g -
string objectName = "EntityTest.Entity.OrderEntity";//Entity type name object obj = new object(); object newobj = new object(); newobj = Convert.ChangeType(obj, Type.GetType(objectName)); I do this I get error -- > Object must implement IConvertible.
My entity OrderEntity has already implemented the IConvertible interface.
Any help/suggestion is greatly appreciated. Is there any other way I can create the object to fulfill my requirement.