TypeConverterAttribute Class
Specifies what type to use as a converter for the object this attribute is bound to. This class cannot be inherited.
Assembly: System (in System.dll)
The class you use for conversion must inherit from TypeConverter. Use the ConverterTypeName property to get the name of the class that provides the data conversion for the object this attribute is bound to.
For more information about attributes, see Attributes Overview and Extending Metadata Using Attributes. For more information about type converters, see the TypeConverter base class and How to: Implement a Type Converter.
The following example tells MyClass to use the type converter called MyClassConverter. This example assumes that MyClassConverter has been implemented elsewhere. The class implementing the converter (MyClassConverter) must inherit from the TypeConverter class.
The next example creates an instance of MyClass. Then it gets the attributes for the class, and prints the name of the type converter used by MyClass.
Public Shared Function Main() As Integer ' Creates a new instance of ClassA. Dim myNewClass As New ClassA() ' Gets the attributes for the instance. Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewClass) ' Prints the name of the type converter by retrieving the ' TypeConverterAttribute from the AttributeCollection. Dim myAttribute As TypeConverterAttribute = _ CType(attributes(GetType(TypeConverterAttribute)), TypeConverterAttribute) Console.WriteLine(("The type conveter for this class is: " _ + myAttribute.ConverterTypeName)) Return 0 End Function 'Main
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.