Export (0) Print
Expand All

Type.Attributes Property

Gets the attributes associated with the Type.

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

Property Value

A TypeAttributes object representing the attribute set of the Type.

Example

[Visual Basic, C++, JScript] The following example shows the use of the Type.Attributes property.

[Visual Basic] 
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#] No example is available for C#. To view a Visual Basic, C++, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Type Class | Type Members | System Namespace | GetAttributeFlagsImpl | TypeAttributes

Show:
© 2014 Microsoft