The predefined type also contains the predefined conversion behavior. For example, there is a predefined conversion between int and long. C # differentiate between the two types of conversions: implicit conversion and display conversion. Implicit conversions refer to safe conversions that do not need to be pointed out carefully. For example, int to long conversion is implicit conversion. This conversion is always successful and will not cause information loss ). The following example: 1 using System;
2 class Test
3 {
4 static void Main ()
5 {
6 int intValue = 123;
7 long longValue = intValue;
8 Console. WriteLine ("{0}, {1}", intValue, longValue );
9}
10} implicitly converts an int type variable to a long type variable ). On the contrary, a conversion expression is required to display the conversion, for example: 1 using System;
2 class Test
3 {
4 static void Main ()
5 {
6 long longValue = Int64.MaxValue;
7 int intValue = (int) longValue;
8 Console. WriteLine ("(int) {0 }={ 1}", longValue, intValue );
9}
10} In the example, the long display is converted to int. The output is (int) 9223372036854775807 =-1 because of overflow. Conversion expressions allow display and implicit conversion.