Type.IsClass 속성

정의

Type이 클래스 혹은 대리자인지, 즉 값 형식 또는 인터페이스가 아닌지 여부를 나타내는 값을 가져옵니다.

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

속성 값

true이 클래스이면 Type이고, 그렇지 않으면 false입니다.

구현

예제

다음 예제에서는 형식의 instance 만들고 형식이 클래스인지 여부를 나타냅니다.

using namespace System;
using namespace System::Reflection;
public ref class MyDemoClass{};

int main()
{
   try
   {
      Type^ myType = Type::GetType( "MyDemoClass" );
      
      // Get and display the 'IsClass' property of the 'MyDemoClass' instance.
      Console::WriteLine( "\nIs the specified type a class? {0}.", myType->IsClass );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}.", e->Message );
   }

}
using System;
using System.Reflection;

public  class MyDemoClass
{
}

public class MyTypeClass
{
    public static void Main(string[] args)
    {
        try
        {
            Type  myType = typeof(MyDemoClass);
            // Get and display the 'IsClass' property of the 'MyDemoClass' instance.
            Console.WriteLine("\nIs the specified type a class? {0}.", myType.IsClass);
        }
        catch(Exception e)
        {
            Console.WriteLine("\nAn exception occurred: {0}." ,e.Message);
        }
    }
}
type MyDemoClass = class end

try
    let myType = typeof<MyDemoClass>
    // Get and display the 'IsClass' property of the 'MyDemoClass' instance.
    printfn $"\nIs the specified type a class? {myType.IsClass}."
with e ->
    printfn $"\nAn exception occurred: {e.Message}."
Imports System.Reflection

Public Class MyDemoClass
End Class

Public Class MyTypeClass
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyDemoClass)
            ' Get and display the 'IsClass' property of the 'MyDemoClass' instance.
            Console.WriteLine(ControlChars.Cr + "Is the specified type a class? {0}.", myType.IsClass.ToString())
        Catch e As Exception
            Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}.", e.Message.ToString())
        End Try
    End Sub
End Class

설명

이 속성은 클래스와 대리자를 반환 true 합니다. 상자가 있는 경우에도 값 형식(구조체 및 열거형의 경우)을 반환 false 합니다.

현재 Type 제네릭 형식 또는 제네릭 메서드의 정의에서 형식 매개 변수를 나타내는 경우 이 속성은 항상 를 반환합니다 true. 현재 Type 생성된 제네릭 형식을 나타내는 경우 이 속성은 제네릭 형식 정의가 클래스 정의인 경우 를 반환 true 합니다. 즉, 인터페이스 또는 값 형식을 정의하지 않습니다.

참고

이 속성은 및 ValueType 클래스를 나타내는 인스턴스에 Enum 대해 Type 를 반환 true 합니다. 이러한 두 클래스는 각각 열거형 및 값 형식의 기본 형식이지만 열거형 또는 값 형식 자체는 아닙니다. 자세한 내용은 IsValueTypeIsEnum 속성을 참조하세요.

열거형 값은 TypeAttributes.ClassSemanticsMask 형식 선언을 클래스 또는 인터페이스로 구분합니다. 그러나 클래스와 값 형식은 모두 특성으로 TypeAttributes.Class 표시됩니다. 형식의 Attributes 속성 값을 검색하고 값을 사용하여 TypeAttributes.ClassSemanticsMask 형식이 값 형식이 아닌 클래스인지 여부를 확인하는 경우 속성도 호출 IsValueType 해야 합니다. 열거형의 TypeAttributes 예제에는 추가 정보와 anexample이 포함되어 있습니다.

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

적용 대상

추가 정보