Numeric Suffixes
This line doesn't compile in C#.float fred=9.0;That's because the default type of a floating point numeric literal - the characters 9.0 is double not float. But a double is twice the size of a float and cannot be stored in a float variable and so the compiler generates a compile error.
To make this compile you either have to cast it to force the issue, which is not very good or add the suffix f (or F).
float fred=9.0f;The compiler makes assumptions about the type of number it determines from the literal text. If it lacks a decimal point then the compiler treats it as an integer. It then chooses the most appropriate size from int, uint, long or ulong. It will though implicitly convert ints to byte, sbyte, short and ushort and float or doubles. So this is ok.
float fred=9;
Integer Suffixes
Without a suffix, the compiler chooses int, uint, long, ulong according to the size of number. You can also use the suffix letters U,u, l or L. U and u mean unsigned, L or l means long. Any 2 letter combination of these letters UL, ul, UL,Ul is ok.Floating Point Suffixes Double doesn't have a suffix. Use f or F for float and M or m for decimal.
Bool Types
Just like in Pascal and C++, C# supports a bool type that takes the values true or false. The result of an expression is a bool and you can assign an expression to a bool variable. You don't need brackets around an expression- except in an if statement as inif ( EndLevel == IsRaised )Either of these two initializations will do, though the second with brackets is possibly clearer. If you use a flag to represent a condition that is true or false, use a bool variable.
DoSomething;
bool endOfRun = EndLevel == IsRaised;
bool endOfRun = ( EndLevel == IsRaised ) ;
if ( endOfRun )
DoSomething;
On the next page : Nullable Types

