Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Type.IsArray Property

 

Gets a value that indicates whether the type is an array.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public bool IsArray { get; }

Property Value

Type: System.Boolean

true if the current type is an array; otherwise, false.

Implements

_Type.IsArray

The IsArray property returns false for the Array class. It also returns false if the current instance is a Type object that represents a collection type or an interface designed to work with collections, such as IEnumerable or IEnumerable<T>.

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.

The following example demonstrates using theIsArray property.

using System;
using System.Collections;
using System.Collections.Generic;

public class Example
{
   public static void Main()
   {
      Type[] types = { typeof(String), typeof(int[]),
                       typeof(ArrayList), typeof(Array),
                       typeof(List<String>),
                       typeof(IEnumerable<Char>) };
      foreach (var t in types)
         Console.WriteLine("{0,-15} IsArray = {1}", t.Name + ":",
                           t.IsArray);
   }
}
// The example displays the following output:
//       String:         IsArray = False
//       Int32[]:        IsArray = True
//       ArrayList:      IsArray = False
//       Array:          IsArray = False
//       List`1:         IsArray = False
//       IEnumerable`1:  IsArray = False

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft