string s = "Hello Reflection";
Type t = s.GetType();
Type t2 = Type.GetType("System.String", false,true);
Type t3 = typeof(string);
其中第二种方式获取Type如何使不同程序集下需要传入完整的程序集版本信息
本文介绍了如何使用C#获取类型Type的三种方法,包括通过对象的GetType()方法,通过Type.GetType()并指定完全限定名,以及使用typeof()操作符。特别是对于第二种方式,当类型位于不同程序集时,需要提供完整的程序集版本信息。
string s = "Hello Reflection";
Type t = s.GetType();
Type t2 = Type.GetType("System.String", false,true);
Type t3 = typeof(string);
其中第二种方式获取Type如何使不同程序集下需要传入完整的程序集版本信息
2457

被折叠的 条评论
为什么被折叠?