2012-05-29 73 views

回答

21

使用Type.IsArray

从MSDN:

int [] array = {1,2,3,4}; 
Type t = array.GetType(); 
// t.IsArray == true 
Console.WriteLine("The type is {0}. Is this type an array? {1}", t, t.IsArray); 
+0

你是对的,我认为它不会工作只是因为它是动态的(GetType不显示在intellisense,当然...),但编译后,它工作正常。谢谢 – RollRoll

1

为什么不 '是' 经营者(我只是做了Visual Studio调试器的立即窗口快速测试),和它的作品。但不知道Tim的答案是否最佳。

void foo(object o) 
{ 
if(o is System.Array) 
{ 
//its array 
} 

} 
相关问题