Click or drag to resize
ConvertChangeType Method (Object, TypeCode)
Returns an object of the specified type whose value is equivalent to the specified object.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static Object ChangeType(
	Object value,
	TypeCode typeCode
)

Parameters

value
Type: SystemObject
An object that implements the IConvertible interface.
typeCode
Type: SystemTypeCode
The type of object to return.

Return Value

Type: Object
An object whose underlying type is typeCode and whose value is equivalent to value.-or-A null reference (Nothing in Visual Basic), if value is null and typeCode is Empty, String, or Object.
Exceptions
ExceptionCondition
InvalidCastExceptionThis conversion is not supported. -or-value is null and typeCode specifies a value type.-or-value does not implement the IConvertible interface.
FormatExceptionvalue is not in a format recognized by the typeCode type.
OverflowExceptionvalue represents a number that is out of the range of the typeCode type.
ArgumentExceptiontypeCode is invalid.
See Also