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