System.Type.IsArray Property

Gets a value indicating whether the Type is an array.

Syntax

public bool IsArray { get; }

Value

true if the current Type represents an array; otherwise false.

Remarks

The Type.IsArray property returns false for the Array class.

To check for an array, use code such as typeof(Array).IsAssignableFrom(type).

If the current Type represents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.

This property is read-only.

Example

The following example demonstrates using the Type.IsArray property.

C# Example

using System;
class TestType {
 public static void Main() {
 int [] array = {1,2,3,4};
 Type at = typeof(Array);
 Type t = array.GetType();
 Console.WriteLine("Type is {0}. IsArray? {1}", at, at.IsArray);
 Console.WriteLine("Type is {0}. IsArray? {1}", t, t.IsArray);
 }
}

The output is

Type is System.Array. IsArray? False
Type is System.Int32[]. IsArray? True

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0