2 <clause number="8.2.2" title="Conversions" informative="true">
3 <paragraph>The predefined types also have predefined conversions. For instance, conversions exist between the predefined types <keyword>int</keyword> and <keyword>long</keyword>. C# differentiates between two kinds of conversions: implicit conversions and explicit conversions. Implicit conversions are supplied for conversions that can safely be performed without careful scrutiny. For instance, the conversion from <keyword>int</keyword> to <keyword>long</keyword> is an implicit conversion. This conversion always succeeds, and never results in a loss of information. The following example <code_example><![CDATA[
9 long longValue = intValue;
10 Console.WriteLine("{0}, {1}", intValue, longValue);
13 ]]></code_example>implicitly converts an <keyword>int</keyword> to a <keyword>long</keyword>. </paragraph>
14 <paragraph>In contrast, explicit conversions are performed with a cast expression. The example <code_example><![CDATA[
19 long longValue = Int64.MaxValue;
20 int intValue = (int) longValue;
21 Console.WriteLine("(int) {0} = {1}", longValue, intValue);
24 ]]></code_example>uses an explicit conversion to convert a <keyword>long</keyword> to an <keyword>int</keyword>. The output is: <code_example><![CDATA[
25 (int) 9223372036854775807 = -1
26 ]]></code_example>because an overflow occurs. Cast expressions permit the use of both implicit and explicit conversions. </paragraph>