這是我的代碼:如何擴展類型類
bool ch=Type.IsBuiltIn("System.Int32"); // not working-> syntax error
public static class MyExtentions
{
public static bool IsBuiltIn(this Type t, string _type)
{
return (Type.GetType(_type) == null) ? false : true;
}
}
請我想IsBuiltIn新方法
這裏你不需要擴展方法 –
把'typeof(int).IsBuiltIn'寫到你的編輯器中。你看到了什麼? – I4V
您傳遞給IsBuiltIn()方法的字符串應該是該類型的程序集限定名稱。我的意思是你應該通過System.Int32 insted只是int – Dimitri