也许是这样;如果你将CLR类型定义为系统核心类型。
,我会删除,如果错了
public static class TypeExtension
{
public static bool IsCLRType(this Type type)
{
var fullname = type.Assembly.FullName;
return fullname.StartsWith("mscorlib");
}
}
交替;
public static bool IsCLRType(this Type type)
{
var definedCLRTypes = new List<Type>(){
typeof(System.Byte),
typeof(System.SByte),
typeof(System.Int16),
typeof(System.UInt16),
typeof(System.Int32),
typeof(System.UInt32),
typeof(System.Int64),
typeof(System.UInt64),
typeof(System.Single),
typeof(System.Double),
typeof(System.Decimal),
typeof(System.Guid),
typeof(System.Type),
typeof(System.Boolean),
typeof(System.String),
/* etc */
};
return definedCLRTypes.Contains(type);
}
你将什么定义为“CLR类型”?这不是一个具有特定单一商定含义的术语:那么,您*意味着什么? – 2013-03-08 10:29:01
我想我正在寻找这个列表:http://msdn.microsoft.com/en-us/library/xa669bew.aspx – Marnix 2013-03-08 10:31:11
在该链接文档中,术语“CLR类型”用于指代可以从CLR中使用,所以在这方面*您可以从CLR中访问的任何*类型是“CLR类型” – Justin 2013-03-08 10:35:08