M_Cyjb_GenericConvert_CanChangeType - CYJB/Cyjb GitHub Wiki

GenericConvert.CanChangeType 方法

返回对象能否从 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

Exceptions

 

异常 条件
ArgumentNullException inputTypenull
ArgumentNullException outputTypenull
ArgumentException inputType 包含泛型参数。
ArgumentException outputType 包含泛型参数。

Remarks

IsImplicitFrom(Type, Type)IsExplicitFrom(Type, Type) 不同, 这里会考虑预定义的隐式、显式类型转换,用户自定义的类型转换(包括 implicitexplicit), 以及通过 AddConverter(TInput, TOutput)(Converter(TInput, TOutput))AddConverterProvider(IConverterProvider) 方法注册的类型转换方法。

参见

Reference

GenericConvert 类
Cyjb 命名空间

⚠️ **GitHub.com Fallback** ⚠️