विवरण
C# में BitConverter.ToInt64() मेथड बाइट ऐरे में निर्दिष्ट स्थिति से आठ बाइट्स को 64-बिट साइन किए गए इंटीजर (long) में परिवर्तित करता है।
सिंटैक्स
public static long ToInt64 (byte[] value, int startIndex);
यहाँ value बाइट ऐरे है और startIndex ऐरे में शुरुआती स्थिति है।
उदाहरण
using System;
public class Demo {
public static void Main() {
byte[] arr = { 0, 10, 15, 20, 26, 30, 34, 42, 50 };
Console.WriteLine("बाइट ऐरे = {0}", BitConverter.ToString(arr));
for (int i = 0; i < arr.Length - 7; i = i + 8) {
long res = BitConverter.ToInt64(arr, i);
Console.WriteLine("\nमान = " + arr[i]);
Console.WriteLine("परिणाम = " + res);
}
}
}
आउटपुट
बाइट ऐरे = 00-0A-0F-14-1A-1E-22-2A-32 मान = 0 परिणाम = 3036022196155648512
एक और उदाहरण
using System;
public class Demo {
public static void Main() {
byte[] arr = {0, 0, 0, 10, 20, 0, 0, 25, 30, 0, 0, 0, 35, 45, 55, 65, 75};
Console.WriteLine("बाइट ऐरे = {0}", BitConverter.ToString(arr));
for (int i = 0; i < arr.Length - 7; i = i + 8) {
long res = BitConverter.ToInt64(arr, i);
Console.WriteLine("\nमान = " + arr[i]);
Console.WriteLine("परिणाम = " + res);
}
}
}
आउटपुट
बाइट ऐरे = 00-00-00-0A-14-00-00-19-1E-00-00-00-23-2D-37-41-4B मान = 0 परिणाम = 1801439937015316480 मान = 30 परिणाम = 4699274364531507230