In most cases, FCL should be used to convert the types provided by FCL (framework class library.
- Use the type conversion operator.
That is, a method (function) inside the type is used. Conversion operators are classified into two types: implicit conversion and display conversion (forced conversion ). Primitive types (the data types directly supported by the compiler and directly mapped to the types in FCL) generally provide conversion operators.
- Use the built-in parse, trypase, or methods such as tostring, todouble, and todatetime.
- Use the methods provided by the help class.
You can use the system. Convert class and system. bitconverter class to convert types.
- Use the transformations supported by CLR.
The transformation supported by CLR, that is, the upward and downward transformation, is actually the mutual conversion between the base class and the subclass. The base class to the base class can be implicitly converted, and the base class rotor class must be a display conversion.
Recommendation 2: use the default Transformation Method