Type.IsInterface 속성

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

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

구문

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

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

속성 값

Type이 인터페이스이면 true이고, 그렇지 않으면 false입니다.

설명

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

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

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

예제

다음 예제에서는 인터페이스를 만들고 인터페이스 형식을 확인하며 클래스에 IsInterface 속성 집합이 있는지 여부를 나타냅니다.

Imports System
Imports Microsoft.VisualBasic
' Declare an interface.
Interface myIFace
End Interface 'myIFace
Class MyIsInterface
    Public Shared Sub Main()
        Try
            ' Get the IsInterface attribute for myIFace.
            Dim myBool1 As Boolean = GetType(myIFace).IsInterface
            ' Display the IsInterface attribute for myIFace.
            Console.WriteLine("Is the specified type an interface? {0}.", myBool1.ToString)
            ' Get the IsInterface attribute for MyIsInterface.
            Dim myBool2 As Boolean = GetType(MyIsInterface).IsInterface
            ' Display the IsInterface attribute for MyIsInterface.
            Console.WriteLine("Is the specified type an interface? {0}.", myBool2.ToString)
        Catch e As Exception
            Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}", e.Message.ToString)
        End Try
    End Sub 'Main
End Class 'MyIsInterface
using System;
// Declare an interface.
interface myIFace
{
}
class MyIsInterface 
{
    public static void Main(string []args)
    {
        try
        {
            // Get the IsInterface attribute for myIFace.
            bool myBool1 = typeof(myIFace).IsInterface;    
            //Display the IsInterface attribute for myIFace.
            Console.WriteLine("Is the specified type an interface? {0}.", myBool1);
            // Get the attribute IsInterface for MyIsInterface.
            bool myBool2 = typeof(MyIsInterface).IsInterface;    
            //Display the IsInterface attribute for MyIsInterface.
            Console.WriteLine("Is the specified type an interface? {0}.", myBool2);         
        }
        catch(Exception e)
        {
            Console.WriteLine("\nAn exception occurred: {0}.", e.Message);
        }
    }
}
using namespace System;

// Declare an interface.
interface class myIFace{};
public ref class MyIsInterface{};

void main()
{
   try
   {
      // Get the IsInterface attribute for myIFace.
      bool myBool1 = myIFace::typeid->IsInterface;
      
      //Display the IsInterface attribute for myIFace.
      Console::WriteLine( "Is the specified type an interface? {0}.", myBool1 );
      
      // Get the attribute IsInterface for MyIsInterface.
      bool myBool2 = MyIsInterface::typeid->IsInterface;
      
      //Display the IsInterface attribute for MyIsInterface.
      Console::WriteLine( "Is the specified type an interface? {0}.", myBool2 );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}.", e->Message );
   }
}
import System.*;

// Declare an interface.
interface myIFace
{
} //myIFace

class MyIsInterface
{
    public static void main(String[] args)
    {
        try {
            // Get the IsInterface attribute for myIFace.
            boolean myBool1 = myIFace.class.ToType().get_IsInterface();

            //Display the IsInterface attribute for myIFace.
            Console.WriteLine("Is the specified type an interface? {0}.",
                System.Convert.ToString(myBool1));

            // Get the attribute IsInterface for MyIsInterface.
            boolean myBool2 = MyIsInterface.class.ToType().get_IsInterface();

            //Display the IsInterface attribute for MyIsInterface.
            Console.WriteLine("Is the specified type an interface? {0}.",
                System.Convert.ToString(myBool2));
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}.",
                e.get_Message());
        }
    } //main
} //MyIsInterface

플랫폼

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
Type.IsClass 속성
IsValueType