C# study notes–conversion of variable types
C# study notes–Conversion of variable types Conversion of variable type: Conversion principle: Large ones of the same type can be installed into small ones, and forced conversion is required to install large ones into small types. Implicit conversion: Conversion of the same type: //Signed long——>int——>short——>sbyte long l = 1; int i = 1; short s = 1; sbyte sb = 1; //Implicit conversion int is implicitly converted to long //You can use a large range to install a small range of types (implicit conversion) l = i; //You cannot use a small range type to fit a large range type //i = l; l = i; l = s; l = sb; i = s; s = sb; ulongul = 1; uint ui = 1; ushort us = 1; byte b = 1; ul = ui; ul = us; ul = b; ui = us; ui = b; us = b; //Floating point number decimal double——>float decimal = 1.1m; double d = 1.1; float f = 1.1f; //There is no way to store double and float in the form of implicit conversion for the decimal type. //de = d; //de = f; //float can be implicitly converted to double d…