c# - Declare a variable using a Type variable -


i have code:

type lefttype = workitem[leftfieldname].gettype(); 

i want declare variable of type:

lefttype somevar; 

is possible?

you can these , cast them known interface.

var somevar = convert.changetype(someoriginalvalue, workitem[leftfieldname].gettype()); var somevar = activator.createinstance(workitem[leftfieldname].gettype()); 

if replace var dynamic (and using .net 4), can call methods expect on somevar object. if don't exist, you'll missingmethodexception.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -