Add a more functional (i.e. fewer-stubs) implementation of System.Data.Linq.
[mono.git] / mcs / docs / ecma334 / 8.11.xml
1 <?xml version="1.0"?>
2 <clause number="8.11" title="Enums" informative="true">
3   <paragraph>An enum type declaration defines a type name for a related group of symbolic constants. Enums are used for &quot;multiple choice&quot; scenarios, in which a runtime decision is made from a fixed number of choices that are known at compile-time. </paragraph>
4   <paragraph>The example <code_example><![CDATA[
5 enum Color   
6 {  
7    Red,  
8    Blue,  
9    Green  
10 }  
11 class Shape  
12 {  
13    public void Fill(Color color) {  
14       switch(color) {  
15          case Color.Red:  
16          ...  
17          break;  
18          case Color.Blue:  
19          ...  
20          break;  
21          case Color.Green:  
22          ...  
23          break;  
24          default:  
25          break;  
26       }  
27    }  
28 }  
29 ]]></code_example>shows a Color enum and a method that uses this enum. The signature of the Fill method makes it clear that the shape can be filled with one of the given colors. </paragraph>
30   <paragraph>The use of enums is superior to the use of integer constants-as is common in languages without  enums-because the use of enums makes the code more readable and self-documenting. The self-documenting nature of the code also makes it possible for the development tool to assist with code writing and other &quot;designer&quot; activities. For example, the use of Color rather than <keyword>int</keyword> for a parameter type enables smart code editors to suggest Color values. </paragraph>
31 </clause>