作者:.NET开发
项目:System.ComponentMode
[TypeConverter(typeof(MyClassConverter))]
public class MyClass {
// Insert code here.
}
作者:.NET开发
项目:System.ComponentMode
public static int Main() {
// Creates a new instance of MyClass.
MyClass myNewClass = new MyClass();
// Gets the attributes for the instance.
AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewClass);
/* Prints the name of the type converter by retrieving the
* TypeConverterAttribute from the AttributeCollection. */
TypeConverterAttribute myAttribute =
(TypeConverterAttribute)attributes[typeof(TypeConverterAttribute)];
Console.WriteLine("The type conveter for this class is: " +
myAttribute.ConverterTypeName);
return 0;
}