Κυριακή 30 Δεκεμβρίου 2007

There are very few absolutes in life; however, I’m about to give you a C# absolute: Every expression has a value and a type. In a declaration such as int n, you can easily see that the variable n is an int. Further, you can reasonably assume that the type of a calculation n + 1 is an int. However, what type is the constant 1? The type of a constant depends on two things: its value and the presence of an optional descriptor letter at the end of the constant. Any integer type less than 2 billion is assumed to be an int. Numbers larger than 2 billion are assumed to be long. Any floating pointing number is assumed to be a double. Table 3-4 demonstrates constants that have been declared to be of a particular type. The case of these descriptors is not important. Thus, 1U and 1u are equivalent.

Δεν υπάρχουν σχόλια: