M_Cyjb_GenericConvert_GetConverter - CYJB/Cyjb GitHub Wiki
获取将对象从 inputType 类型转换为 outputType 类型的转换器。
Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6
C#
public static Converter<Object?, Object?>? GetConverter(
Type inputType,
Type outputType
)
- inputType
- Type: System.Type
要转换的对象的类型。 - outputType
- Type: System.Type
要将输入对象转换到的类型。
Type: Converter(Object, Object)
将对象从 inputType 类型转换为 outputType 类型的转换器。 如果不存在则为 null
。
异常 | 条件 |
---|---|
ArgumentNullException |
inputType 为 null 。 |
ArgumentNullException |
outputType 为 null 。 |
ArgumentException | inputType 包含泛型参数。 |
ArgumentException | outputType 包含泛型参数。 |
尽可能使用泛型方法 GetConverter(TInput, TOutput)(),这样可以避免额外的类型转换。