可以在c#中获取别名类型的类型?

Type.GetType("System.String") 

是否有查找某处可用的别名?

 Type.GetType("string") 

返回null

这在程序上是不可能的,因为’别名’实际上是在C#中引入的关键字,而Type.GetType (与所有其他框架方法一样)是与语言无关的框架的一部分。

您可以使用以下值创建字典:

  bool System.Boolean byte System.Byte sbyte System.SByte char System.Char decimal System.Decimal double System.Double float System.Single int System.Int32 uint System.UInt32 long System.Int64 ulong System.UInt64 object System.Object short System.Int16 ushort System.UInt16 string System.String 

“别名”是语言定义的一部分。 您需要在相关语言规范中查找它们。 它们被编译掉,并且在运行时不存在 – 字符串变为System.String,int变为System.Int32等。

别名(int,bool等)未在CLS中定义。 它们只是编译时常量,在运行时被替换。 这意味着当程序运行时,你可以“以编程方式”执行操作,别名已经消失。你只能这样做:

 Type.GetType(typeof (string).ToString())