如果C#可以将int转换为对象,为什么不将int []转换为对象[]?
void Main()
{
var a = new String[]{"0", "1"};
var b = new int[]{0, 1};
AssertMoreThan1(a); // No Exception
AssertMoreThan1(b); // Exception
}
static void AssertMoreThan1(params object[] v){
if(v.Length == 1){
throw new Exception("Too Few Parameters");
}
}
Run Code Online (Sandbox Code Playgroud)