This is the working code for UInt64 numbers which mean that you can insert From 0 to 18,446,744,073,709,551,615 which equals 2^64 − 1 numbers.
I have also commented the code so to be understandable.
This is Consoled based algorythm just change it and modify it into your app!
Execution Result:
I have also commented the code so to be understandable.
This is Consoled based algorythm just change it and modify it into your app!
Code
//First of all we need UInt64 to calculate really long numbers.
string Input = "18446744073709551615,100";
/*We split the numbers in the text by ',' (comma)
and put them in an array named Numbers*/
string[] Numbers = Input.Split(',');
//This will help us to convert the string into number.
UInt64[] ConvertedNum = new UInt64[Numbers.Length];
/*We convert the string into an integer and put it
in the tolur array.*/
for (int i = 0; i < Numbers.Length; i++)
{
ConvertedNum[i] = Convert.ToUInt64(Numbers[i]);
}
//We Find the Difference between the max and the min Number.
UInt64 Difference = ConvertedNum.Max() - ConvertedNum.Min();
Console.WriteLine("Were read into the numbers:\n" + Input +
"\nBut the difference between the highest and lowest number is:\n" + Difference);
Console.ReadKey();Execution Result:
Code
Were read into the numbers:
18446744073709551615,100
But the difference between the highest and lowest number is:
18446744073609551615