Export (0) Print
Expand All

LanguagePrimitives.ConvertTo Method (Object, Type)

Converts an object from one type to another.


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

'Usage
Dim valueToConvert As Object
Dim resultType As Type
Dim returnValue As Object

returnValue = LanguagePrimitives.ConvertTo(valueToConvert, resultType)

public static Object ConvertTo (
	Object valueToConvert,
	Type resultType
)
public static Object ConvertTo (
	Object valueToConvert, 
	Type resultType
)
public static function ConvertTo (
	valueToConvert : Object, 
	resultType : Type
) : Object

Parameters

valueToConvert

The object to convert.

resultType

The type of object to convert to.

Return Value

The converted object.

Exception typeCondition
ArgumentNullException

resultType is null.

PSInvalidCastException

Windows PowerShell cannot convert the object.

-or-

A custom converter threw an exception.

Windows PowerShell can use standard Windows PowerShell language converters or custom converters to perform the type conversion. For more information about these converters, possible return values, and exceptions that might be thrown during the conversion process, see ETS Type Conversion.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

 

Target Platforms


Show:
© 2015 Microsoft