asp.net.ph

IConvertible Interface

System Namespace


Defines methods that convert the value of the implementing reference or value type to a common language runtime type that has an equivalent value.

The IConvertible type is not CLS-compliant. For more information about CLS compliance, see What is the Common Language Specification.

IConvertible Interface Members

Collapse   Methods

Visibility Name Parameters Return Type
public GetTypeCode ( ) TypeCode
public ToBoolean ( IFormatProvider provider ) Boolean
public ToByte ( IFormatProvider provider ) Byte
public ToChar ( IFormatProvider provider ) Char
public ToDateTime ( IFormatProvider provider ) DateTime
public ToDecimal ( IFormatProvider provider ) Decimal
public ToDouble ( IFormatProvider provider ) Double
public ToInt16 ( IFormatProvider provider ) Int16
public ToInt32 ( IFormatProvider provider ) Int32
public ToInt64 ( IFormatProvider provider ) Int64
public ToSByte ( IFormatProvider provider ) SByte
public ToSingle ( IFormatProvider provider ) Single
public ToString ( IFormatProvider provider ) String
public ToType ( Type conversionType , IFormatProvider provider ) Object
public ToUInt16 ( IFormatProvider provider ) UInt16
public ToUInt32 ( IFormatProvider provider ) UInt32
public ToUInt64 ( IFormatProvider provider ) UInt64

Classes that Implement IConvertible


Class Description
DBNull Represents a null value.
Enum Provides the base class for enumerations.
String Represents an immutable series of characters.

Remarks

This interface provides methods to convert the value of an instance of an implementing type to a common language runtime type that has an equivalent value. The common language runtime types are Boolean, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, DateTime, Char, and String.

If there is no meaningful conversion to a common language runtime type, then a particular interface method implementation throws InvalidCastException. For example, if this interface is implemented on a Boolean type, the implementation of the ToDateTime method throws an exception because there is no meaningful DateTime equivalent to a Boolean type.

The common language runtime typically exposes the IConvertible interface through the Convert class. The common language runtime also uses the IConvertible interface internally, in explicit interface implementations, to simplify the code used to support conversions in the Convert class and basic common language runtime types.

In addition to the IConvertible interface, the .NET Framework provides classes called type converters for converting user-defined data types to other data types. For more information, see the Generalized Type Conversion topic.

Skip Navigation Links



Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph