Type.IsArray Property
Gets a value indicating whether the Type is an array.
[Visual Basic] Public ReadOnly Property IsArray As Boolean [C#] public bool IsArray {get;} [C++] public: __property bool get_IsArray(); [JScript] public function get IsArray() : Boolean;
Property Value
true if the Type is an array; otherwise, false.
Remarks
The Array class returns false because it is not an array.
To check for an array, use code such as typeof(Array).IsAssignableFrom(type).
This property is read-only.
Example
[Visual Basic, C#, C++] The following example demonstrates using the IsArray property.
[Visual Basic] Imports System Class TestIsArray Public Shared Sub Main() Dim array As Integer() = {1, 2, 3, 4} Dim at As Type = GetType(Array) Dim t As Type = 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) End Sub 'Main End Class 'TestType [C#] 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); } } [C++] #using <mscorlib.dll> using namespace System; int main() { Int32 array[] = {1, 2, 3, 4}; Type* at = __typeof(Array); Type* t = array->GetType(); Console::WriteLine(S"The type is {0}. Is this type an array? {1}", at, at->IsArray.ToString()); Console::WriteLine(S"The type is {0}. Is this type an array? {1}", t, t->IsArray.ToString()); }
[Visual Basic, C#, C++] This code produces the following output:
Type is System.Array. IsArray? False
Type is System.Int32[]. IsArray? True [JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard