Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Windows Forms Programming 
Generalized Type Conversion 

The .NET Framework provides the following two mechanisms for converting user-defined data types (custom types) to other data types:

The following table highlights the differences between these two mechanisms.

NoteNote

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.

NoteNote

A TypeConverter for a type is implemented outside the type and associated with the type by applying a TypeConverterAttribute attribute.

NoteNote

IConvertible is implemented by a custom type. To convert a type, a user of the type invokes a conversion method (of the IConvertible contract) on the type.

For details about using type converters to perform conversions, see System.ComponentModel.TypeConverter. For information about implementing a type converter to provide design-time support for a custom type, see Implementing a Type Converter.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker