I have a byte array value of 10 elements taken from an sql_variant
column in my database table and would like to convert it to a long value. I tried this.
byte []a = new byte[10]{ 127, 1, 0, 202, 154, 59, 0, 0, 0, 0 };
long i = BitConverter.ToInt64(a, 0);
Console.WriteLine("{0}", i);
but it's not giving me the correct result. I expect it to be 10000000000
.
Thank you if you could offer me some ideas of classes or methods in C# I can look up into.
10000000000 in a hex notation is 02540BE400.
Byte array for this value in reverse order is:
or in a decimal notation:
For this array your function returns expected result: 10000000000.