2009-12-09 Jb Evain <jbevain@novell.com>
[mcs.git] / docs / ecma334 / 13.xml
blob400798091eae76c1936ad73520ca7958311900c3
1 <?xml version="1.0"?>
2 <clause number="13" title="Conversions">
3   <paragraph>A conversion enables an expression of one type to be treated as another type. Conversions can be implicit or explicit, and this determines whether an explicit cast is required. <example>[Example: For instance, the conversion from type <keyword>int</keyword> to type <keyword>long</keyword> is implicit, so expressions of type <keyword>int</keyword> can implicitly be treated as type <keyword>long</keyword>. The opposite conversion, from type <keyword>long</keyword> to type <keyword>int</keyword>, is explicit and so an explicit cast is required. <code_example><![CDATA[
4 int a = 123;  
5 long b = a;     // implicit conversion from int to long  
6 int c = (int) b;  // explicit conversion from long to int  
7 ]]></code_example>end example]</example> Some conversions are defined by the language. Programs may also define their own conversions (<hyperlink>13.4</hyperlink>). </paragraph>
8 </clause>