Check if a object is an array in CSharp
Description
The following code shows how to check if a object is an array.
Example
// ww w .j a v a2 s. c o m
using System;
class TestIsArray
{
public static void Main()
{
int [] array = {1,2,3,4};
Type at = typeof(Array);
Type t = array.GetType();
Console.WriteLine("The type is {0}. Is this type an array? {1}", at, at.IsArray);
Console.WriteLine("The type is {0}. Is this type an array? {1}", t, t.IsArray);
}
}
The code above generates the following result.