Type.IsClass 속성

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

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public ReadOnly Property IsClass As Boolean
‘사용 방법
Dim instance As Type
Dim value As Boolean

value = instance.IsClass
public bool IsClass { get; }
public:
virtual property bool IsClass {
    bool get () sealed;
}
/** @property */
public final boolean get_IsClass ()
public final function get IsClass () : boolean

속성 값

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

설명

이 속성은 EnumValueType을 나타내는 Type 인스턴스에 대해 true를 반환합니다.

ClassSemanticsMask는 형식 선언을 클래스, 인터페이스 또는 값 형식으로 구별합니다.

현재 Type이 생성된 제네릭 형식을 나타내는 경우 이 속성은 제네릭 형식 정의가 클래스 정의이면, 즉 인터페이스나 값 형식을 정의하지 않으면 true를 반환합니다.

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

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

예제

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

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class MyDemoClass
End Class 'MyDemoClass

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 'Main
End Class 'MyTypeClass
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);
        }
    }
}
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 );
   }

}
import System.*;
import System.Reflection.*;
public class MyDemoClass
{
} //MyDemoClass

public class MyTypeClass
{
    public static void main(String[] args)
    {
        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}.", System.
                Convert.ToString(myType.get_IsClass()));
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}.", e.get_Message());
        }
    } //main
} //MyTypeClass

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Type 클래스
Type 멤버
System 네임스페이스
TypeAttributes
IsInterface
IsValueType