TypeLibVarAttribute Class
Contains the VARFLAGS that were originally imported for this field from the COM type library.
For a list of all members of this type, see TypeLibVarAttribute Members.
System.Object
System.Attribute
System.Runtime.InteropServices.TypeLibVarAttribute
[Visual Basic] <AttributeUsage(AttributeTargets.Field)> NotInheritable Public Class TypeLibVarAttribute Inherits Attribute [C#] [AttributeUsage(AttributeTargets.Field)] public sealed class TypeLibVarAttribute : Attribute [C++] [AttributeUsage(AttributeTargets::Field)] public __gc __sealed class TypeLibVarAttribute : public Attribute [JScript] public AttributeUsage(AttributeTargets.Field) class TypeLibVarAttribute extends Attribute
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
The Type Library Importer (Tlbimp.exe) applies this attribute to fields.
This attribute is applied when a type library is imported and should never be changed. It is only applied when the method's VARFLAGS evaluate to non-zero. The attribute is designed to be used by tools that need to know how the original VARFLAGS were set. The common language runtime does not use this attribute.
Example
[Visual Basic, C#, C++] The following example demonstrates how to get the TypeLibVarAttribute value of a field.
[Visual Basic] Imports System Imports System.Reflection Imports System.Runtime.InteropServices Module D Public Function IsHiddenField(ByVal fi As FieldInfo) As Boolean Dim FieldAttributes As Object() = fi.GetCustomAttributes(GetType(TypeLibVarAttribute), True) If FieldAttributes.Length > 0 Then Dim tlv As TypeLibVarAttribute = FieldAttributes(0) Dim flags As TypeLibVarFlags = tlv.Value Return (flags & TypeLibVarFlags.FHidden) > 0 End If Return False End Function End Module [C#] using System; using System.Reflection; using System.Runtime.InteropServices; namespace D { class ClassD { public static bool IsHiddenField( FieldInfo fi ) { object[] FieldAttributes = fi.GetCustomAttributes( typeof( TypeLibVarAttribute ), true); if( FieldAttributes.Length > 0 ) { TypeLibVarAttribute tlv = ( TypeLibVarAttribute )FieldAttributes[0]; TypeLibVarFlags flags = tlv.Value; return ( flags & TypeLibVarFlags.FHidden ) != 0; } return false; } } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; using namespace System::Runtime::InteropServices; __gc class ClassD { public: static bool IsHiddenField( FieldInfo* fi ) { Object* FieldAttributes[] = fi->GetCustomAttributes( __typeof( TypeLibVarAttribute ), true); if( FieldAttributes->Length > 0 ) { TypeLibVarAttribute* tlv = dynamic_cast<TypeLibVarAttribute*>(FieldAttributes[0]); TypeLibVarFlags flags = tlv->Value; return ( flags & TypeLibVarFlags::FHidden ) != 0; } return false; } };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Runtime.InteropServices
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: Mscorlib (in Mscorlib.dll)
See Also
TypeLibVarAttribute Members | System.Runtime.InteropServices Namespace | Type Library Importer (Tlbimp.exe)