Changes

Jump to: navigation, search

C Sharp Variables and Constants

1,101 bytes added, 18:31, 11 January 2008
What is a C# Constant?
</pre>
will result in a compilation error along the lines of ''A const field requires a value to be provided''.Now that we have described C# variable and constants it is time to start looking at the different ''types''. == C# Integer Variable Types == Perhaps the most widely used of the variable types is the integer. C# provides a number of different integer types based on number size and whether the integers are signed (positive only) or unsigned (positive or negative). All the integer variable types have one thing in common and that is that they may only be used to store whole numbers. The following table lists the various C# integer variable types together details of the number of bytes of physical memory consumed by each type and the acceptable value ranges. <table border="1" cellspacing="0"><tr style="background:#efefef;"><th>Type</th><th>Size in Bytes</th><th>Value Range</th><tr><td>byte<td>1 byte<td>0 to 255</td><tr><td>sbyte<td>1 byte<td>-128 - 127</td><tr><td>short<td>2 bytes<td>-32,768 - 32,767</td><tr><td>ushort<td>2 bytes<td>0 - 65,535</td><tr><td>int<td>4 bytes<td>-2,147,483,648 - 2,147,483,648</td><tr><td>uint<td>4 bytes<td>0 - 4,294,967,295</td><tr> </table>

Navigation menu