sTypeName = ... //do some string stuff here to get the name of the type
/*
The Assembly.CreateInstance function returns a type
of System.object. I want to type cast it to
the type whose name is sTypeName.
assembly.CreateInstance(sTypeName)
So, in effect I want to do something like:
*/
assembly.CreateInstance(sTypeName) as Type.GetType(sTypeName);
我该怎么做?而且,假设这是C#2.0,我该如何在赋值表达式的左侧进行操作。我没有var关键字。从类型名称的字符串表示类型转换为类型
谢谢,我已经完成(2)并正在寻找选项。 – 2010-04-15 09:30:58