This documentation is archived and is not being maintained.

Convert.ChangeType Method (Object, Type)

Returns an object of the specified type and whose value is equivalent to the specified object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static Object ChangeType(
	Object value,
	Type conversionType


Type: System.Object
An object that implements the IConvertible interface.
Type: System.Type
The type of object to return.

Return Value

Type: System.Object
An object whose type is conversionType and whose value is equivalent to value.
A null reference (Nothing in Visual Basic), if value is null and conversionType is not a value type.


This conversion is not supported.


value is null and conversionType is a value type.


value does not implement the IConvertible interface.


value is not in a format recognized by conversionType.


value represents a number that is out of the range of conversionType.


conversionType is null.

ChangeType is a general-purpose conversion method that converts the object specified by value to conversionType. The value parameter can be an object of any type, and conversionType can also be a Type object that represents any base or custom type. For the conversion to succeed, value must implement the IConvertible interface, because the method simply wraps a call to an appropriate IConvertible method. The method requires that conversion of value to conversionType be supported.

This method uses the current thread's culture for the conversion.

The following example illustrates the use of the ChangeType method.

using System;

public class ChangeTypeTest {
    public static void Main() {

        Double d = -2.345;
        int i = (int)Convert.ChangeType(d, typeof(int));

        Console.WriteLine("The double value {0} when converted to an int becomes {1}", d, i);

        string s = "12/12/98";
        DateTime dt = (DateTime)Convert.ChangeType(s, typeof(DateTime));

        Console.WriteLine("The string value {0} when converted to a Date becomes {1}", s, dt);        

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.