Share via


Type.Attributes プロパティ

Type に関連付けられている属性を取得します。

Public ReadOnly Property Attributes As TypeAttributes
[C#]
public TypeAttributes Attributes {get;}
[C++]
public: __property TypeAttributes get_Attributes();
[JScript]
public function get Attributes() : TypeAttributes;

プロパティ値

Type の属性のセットを表す TypeAttributes オブジェクト。

使用例

[Visual Basic, C++, JScript] Type.Attributes プロパティを使用する例を次に示します。

 
Imports System
Imports System.Reflection

Public Class Class1
    Protected t As Type
    Public Sub Method1()
        If t.Attributes And TypeAttributes.ClassSemanticsMask = TypeAttributes.Interface Then
            Console.WriteLine("t is an interface.")
        End If
        If t.Attributes And TypeAttributes.Public <> 0 Then
            Console.WriteLine("t is public.")
        End If
    End Sub 'Method1
End Class 'Class1

[C++] 

#using <mscorlib.dll>
#using <System.DLL>

using namespace System;
using namespace System::Reflection;

__gc class Sample
{
    void Method(Type* t)
    {

        if ((t->Attributes & TypeAttributes::ClassSemanticsMask) == TypeAttributes::Interface)
            Console::WriteLine ("t is an interface.");
        if ((t->Attributes & TypeAttributes::Public) != 0)
            Console::WriteLine ("t is public.");
    }
};

[JScript] 
if ((t.Attributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
    Console.WriteLine ("t is an Interface");
if ((t.Attributes & TypeAttributes.Public) != 0)
    Console.WriteLine ("t is public");

[C#] C# のサンプルはありません。Visual Basic、C++、および JScript のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

Type クラス | Type メンバ | System 名前空間 | GetAttributeFlagsImpl | TypeAttributes