M_Cyjb_GenericConvert_ChangeType - CYJB/Cyjb GitHub Wiki
返回指定类型的对象,其值等效于指定对象。
Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6
C#
public static Object? ChangeType(
Object? value,
Type outputType
)
- value
- Type: System.Object
要转换的对象。 - outputType
- Type: System.Type
要将 value 转换到的类型。
Type: Object
一个对象,其类型为 outputType, 并且其值等效于 value。
异常 | 条件 |
---|---|
ArgumentNullException |
outputType 为 null 。 |
InvalidCastException |
value 为 null , 而且 outputType 是值类型。 |
InvalidCastException | 不支持此转换。 |
尽可能使用泛型方法 ChangeType(TInput, TOutput)(TInput),这样可以避免额外的类型转换。