Long and ulong are very similar to Integer type ( int ) but has a very high range of numbers that it can accept. Long has a range of about –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and ulong has a range of about 0 to 18,446,744,073,709,551,615.
While using long datatype and assigning a long value to a variable, its recommended to suffix L with the number being assigned.
long x = 1234567890L; (something like this for long)
ulongx = 1234567890uL; (something like this for ulong)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
long a = 1234567890L;
long b = 1234567890L;
long c = a * b;
Console.WriteLine("The
addition of two signed long numbers {0} and {1} is : {2}", a, b,
c);
Console.ReadLine();
ulong d = 1234567890uL;
ulong e = 1234567890uL;
ulong f = d * e;
Console.WriteLine("The
addition of two unsigned long numbers {0} and {1} is : {2}", d, e,
f);
Console.ReadLine();
}
}
}
Output :
No comments:
Post a Comment