How to check if a dynamic object is an array in c#?
Why not just 'is' operator (I just did quick test on immediate windows of Visual Studio debugger), and it works. but not sure if Tim's answer is optimal.
void foo(object o)
{
if( o is System.Array)
{
//its array
}
}
Use Type.IsArray
:
From 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);