adddesign

By Think Positive, Get Positive on 3:11:00 PM

Filed Under: , , ,

Integers:

  • C# defines nine integer types and they are char, byte, sbyte, short, ushort, int, uint, long and ulong.
  • The bit width and ranges of integers are shown below
TYPE --------------- WIDTH in bits ----------------RANGE
  1. byte ------------------------- 8 -------------------------0 to 255
  2. sbyte------------------------- 8 -------------------- -128 to 127
  3. short -------------------------16---------------- -32768 to 32767
  4. ushort----------------------- 16--------------------------- 0 to 65535
  5. int ----------------------------32---------- -2147483648 to 2147483647
  6. uint --------------------------32 --------------------------- 0 to 4294965295
  7. long-------------------------- 64-------- 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  8. ulong ------------------------64 -----------------------------0 to 18,446,744,073,709,551,615
Program using Long variable for large signed values:

using system;
class inch
{
public static void Main()
{
long mile;
long inch;
mile = 93000000;
inch = mile*5280*12;
Console.WriteLine("The distance to the Sun:"+inch+"inches");
}
}

Output:

The distance to the Sun: 5892480000000 inches

Program using byte to control the for loop that produces the summation of the number 100

using system;
class using_byte
{
public static void Main()
{
byte x;
int y;
y=0;
for(x=1;x<+100;x++)
y=y+x;
Console.WriteLine("The sum of 100 is "+y);
}
}

output:

The sum of 100 is 5050

goto Double

0 comments for this post