T_Cyjb_GenericConvert - CYJB/Cyjb GitHub Wiki

GenericConvert 类

提供将一种类型转换为另一种类型的方法。

继承层次

System.Object
  Cyjb.GenericConvert
Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public static class GenericConvert

The GenericConvert type exposes the following members.

方法

 

名称 说明
公共方法静态成员 AddConverter(TInput, TOutput) 添加将对象从 TInput 类型转换为 TOutput 类型的转换器。
公共方法静态成员 AddConverterProvider 添加指定的类型转换器提供者。
公共方法静态成员 CanChangeType 返回对象能否从 inputType 类型转换为 outputType 类型。
公共方法静态成员 ChangeType(Object, Type) 返回指定类型的对象,其值等效于指定对象。
公共方法静态成员 ChangeType(TInput, TOutput)(TInput) 返回指定类型的对象,其值等效于指定对象。
公共方法静态成员 GetConverter(Type, Type) 获取将对象从 inputType 类型转换为 outputType 类型的转换器。
公共方法静态成员 GetConverter(TInput, TOutput)() 获取将对象从 TInput 类型转换为 TOutput 类型的转换器。
公共方法静态成员 GetConverterType 返回具有指定输入和输出类型的 Converter(TInput, TOutput) 类型。
  Back to Top

Remarks

支持预定义的隐式、显式类型转换,用户自定义类型转换(Implicit 和 Explicit 运算符), 并可以通过 AddConverter(TInput, TOutput)(Converter(TInput, TOutput))AddConverterProvider(IConverterProvider) 方法注入额外的类型转换方法。

默认添加了所有类型转换为字符串,和字符串转换为数字、布尔和日期/时间的额外方法。

所有数值类型转换,都会对溢出进行检查,如果数值不在范围内则会抛出异常。

参见

Reference

Cyjb 命名空间

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