Type.IsInterface プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Type.IsInterface プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


このプロパティは、アンマネージ コードからマネージ クラスにアクセスするためのプロパティであるため、マネージ コードからは呼び出さないでください。
Type.IsInterface プロパティは、Type がクラスや値型ではなく、インターフェイスであるかどうかを示す値を取得します。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Type.IsInterfaceのページへのリンク