Type.IsArray 속성

정의

유형이 배열인지 여부를 나타내는 값을 가져옵니다.

public:
 virtual property bool IsArray { bool get(); };
public:
 property bool IsArray { bool get(); };
public virtual bool IsArray { get; }
public bool IsArray { get; }
member this.IsArray : bool
Public Overridable ReadOnly Property IsArray As Boolean
Public ReadOnly Property IsArray As Boolean

속성 값

Boolean

현재 유형이 배열이면 true이고, 그렇지 않으면 false입니다.

구현

예제

다음 예제에서는 사용 하는 IsArray 속성입니다.

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
Imports System.Collections
Imports System.Collections.Generic

Module Example
   Public Sub Main()
      Dim types() As Type = { GetType(String), GetType(Integer()),
                              GetType(ArrayList), GetType(Array),
                              GetType(List(Of String)),
                              GetType(IEnumerable(Of Char)) }
      For Each t In types
         Console.WriteLine("{0,-15} IsArray = {1}", t.Name + ":", t.IsArray)
      Next
   End Sub
End Module
' 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

설명

IsArray속성은 false 클래스에 대해 를 Array 반환합니다. false또한 현재 인스턴스가 컬렉션 Type 형식을 나타내는 개체이거나 또는 와 같은 컬렉션에서 작동하도록 설계된 인터페이스인 경우에도 를 IEnumerable 반환합니다. IEnumerable<T>

배열을 확인하려면 다음과 같은 코드를 사용합니다.

typeof(Array).IsAssignableFrom(type)  
GetType(Array).IsAssignableFrom(type)  

현재 형식이 제네릭 형식 또는 제네릭 형식 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 경우 이 속성은 항상 false 를 반환합니다.

이 속성은 읽기 전용입니다.

적용 대상

추가 정보