_Type.IsInterfaceとは? わかりやすく解説

Type.IsInterface プロパティ

Typeインターフェイスであり、クラス値型でないかどうかを示す値を取得します

名前空間: System
アセンブリ: 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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Type.IsInterface プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

COM オブジェクトに、Type.IsInterface プロパティへのバージョン依存しないアクセス用意されています。

このプロパティは、CLS準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As _Type
Dim value As Boolean

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

プロパティ
Typeインターフェイスである場合trueそれ以外場合false

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」から_Type.IsInterfaceを検索した結果を表示しています。
Weblioに収録されているすべての辞書から_Type.IsInterfaceを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書から_Type.IsInterfaceを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「_Type.IsInterface」の関連用語

_Type.IsInterfaceのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



_Type.IsInterfaceのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS