The .NET Framework provides the following two mechanisms for converting user-defined data types (custom types) to other data types:
Defining a type converter for a custom type by extending the System.ComponentModelTypeConverter class and associating the type converter with the type through a System.ComponentModelTypeConverterAttribute attribute.
Implementing the SystemIConvertible interface on a custom type.
The following table highlights the differences between these two mechanisms.
Design-time support can be provided for a custom type only if it has a type converter defined for it.
Conversion using TypeConverter
Conversion using IConvertible
Can be used both at design time and at run time.
Can be used only at run time.
Uses reflection; therefore, is slower than conversion enabled by IConvertible.
Does not use reflection.
Allows two-way type conversions from the custom type to other data types and from other data types to the custom type. For example, a TypeConverter defined for MyType allows conversions from MyType to String and from String to MyType.
Allows conversion from a custom type to other data types but not from other data types to the custom type.
For details about using type converters to perform conversions, see System.ComponentModelTypeConverter. For information about implementing a type converter to provide design-time support for a custom type, see Implementing a Type Converter.