M_Cyjb_GenericConvert_CanChangeType - CYJB/Cyjb GitHub Wiki
返回对象能否从 inputType 类型转换为 outputType 类型。
Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6
C#
public static bool CanChangeType(
Type inputType,
Type outputType
)
- inputType
- Type: System.Type
要转换的对象的类型。 - outputType
- Type: System.Type
要将输入对象转换到的类型。
Type: Boolean
如果对象能够从 inputType 类型转换为 outputType 类型, 则为 true
。否则为 false
。
异常 | 条件 |
---|---|
ArgumentNullException |
inputType 为 null 。 |
ArgumentNullException |
outputType 为 null 。 |
ArgumentException | inputType 包含泛型参数。 |
ArgumentException | outputType 包含泛型参数。 |
与 IsImplicitFrom(Type, Type) 或 IsExplicitFrom(Type, Type) 不同, 这里会考虑预定义的隐式、显式类型转换,用户自定义的类型转换(包括 implicit
和 explicit
), 以及通过 AddConverter(TInput, TOutput)(Converter(TInput, TOutput)) 和 AddConverterProvider(IConverterProvider) 方法注册的类型转换方法。