Type.IsInterface 속성
정의
public:
property bool IsInterface { bool get(); };
public bool IsInterface { get; }
member this.IsInterface : bool
Public ReadOnly Property IsInterface As Boolean
속성 값
구현
예제
다음 예제에서는 인터페이스를 만듭니다 인터페이스 형식을 확인 하 고 클래스에 있는지 여부를 나타냅니다는 IsInterface
속성 집합입니다.The following example creates an interface, checks for the interface type, and indicates whether a class has the IsInterface
property set.
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 );
}
}
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);
}
}
}
' Declare an interface.
Interface IInterface
End Interface
Class Example : Implements IInterface
Public Shared Sub Main()
' Determine whether IInterface is an interface.
Dim isInterface1 As Boolean = GetType(IInterface).IsInterface
Console.WriteLine("Is IInterface an interface? {0}", isInterface1)
' Determine whether Example is an interface.
Dim isInterface2 As Boolean = GetType(Example).IsInterface
Console.WriteLine("Is Example an interface? {0}", isInterface2)
End Sub
End Class
' The example displays the following output:
' Is IInterface an interface? True
' Is Example an interface? False
설명
ClassSemanticsMask 형식 선언을 클래스, 인터페이스 또는 값 형식으로 구분 합니다.The ClassSemanticsMask distinguishes a type declaration as class, interface or value type.
하는 경우 현재 Type 이 속성은 항상 제네릭 형식 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 false
합니다.If the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns false
.
이 속성은 읽기 전용입니다.This property is read-only.