Jump to: navigation, search

C Sharp Variables and Constants

281 bytes added, 19:34, 11 January 2008
C# Character Variable Type
<table border="1" cellspacing="0">
<tr style="background:#efefef;">
<th>Type</th><th>Size in BytesCharacter Constant</th><th>Special Value Range</th><th>Digit Accuracy</th>
<td>float\n<td>8 bytes<td>1.5 * 10<sup>-45</sup> to 3.4 * 10<sup>38</sup><td> 6 - 7 digitsNew Line</td>
<td>double\t<td>16 bytesTab</td>5.<tr><td>\0 * 10<suptd>-324Null</suptd> to 1.7 * 10<suptr>308<td>\r<td>Carriage Return</suptd><tr><td>\\<td>15 - 16 digitsBackslash</td>
Note that there is a special character sequence for the Backslash (\\). Because the special characters begin with a backslash the compiler interprets any instances of a single backslash as the pre-cursor to a special character. This raises the question of what to do if you really want a backslash. The answer is to use the double backslash special constant sequence.
== C# String Variables ==
In the preceding section we looked at storing individual characters in a ''char'' variable. Whilst this works for storing a single letter or number it is of little use for storing entire words or sentences. For this purpose the ''string'' variable type is supported by C#. Variables of type ''string'' can store a string of any number of characters.

Navigation menu