Thursday, February 10, 2011

Primitive Types

For every Java primitive type there is a corresponding C# type which has the same name (except for byte). The byte type in Java is signed and is thus analagous to the sbyte type in C# and not the byte type.C# also has unsigned versions of some primitives such as ulong, uint, ushort and byte . The only significantly different primitive in C# is the decimal type, a type which stores decimal numbers without rounding errors (at the cost of more space and less speed).

Below are different ways to declare real valued numbers in C#.
C# Code

decimal dec = 100.44m; //m is the suffix used to specify decimal numbers
double dbl = 1.44e2d; //e is used to specify exponential notation while d is the suffix used for doubles

No comments:

Post a Comment