The following doesn\'t work, of course. Is there a possible way, which is pretty similar like this?
Type newObjectType = typeof(MyClass); var newObject = gi
You can use Convert.ChangeType. According to msdn, it
returns an object of a specified type whose value is equivalent to a specified object.
You could try the code below:
Type newObjectType = typeof(MyClass); var newObject = Convert.ChangeType(givenObject, newObjectType);