C# में BitConverter.ToUInt32() मेथड का उपयोग बाइट ऐरे में निर्दिष्ट स्थिति पर चार बाइट्स से परिवर्तित 32-बिट अनसाइन्ड इंटीजर वापस करने के लिए किया जाता है।
सिंटैक्स
public static uint ToUInt32 (byte[] val, int begnIndex);
ऊपर, val बाइट ऐरे है, जबकि begnIndex val के भीतर शुरुआती स्थिति है।
उदाहरण
using System;
public class Demo {
public static void Main() {
byte[] arr = { 0, 3, 5, 10, 15, 2};
int count = arr.Length;
Console.Write("बाइट ऐरे... ");
for (int i = 0; i < count; i++) {
Console.Write("\n" + arr[i]);
}
Console.WriteLine("\n\nबाइट ऐरे (स्ट्रिंग प्रतिनिधित्व) = {0} ",
BitConverter.ToString(arr));
for (int i = 1; i < arr.Length - 1; i = i + 4) {
uint res = BitConverter.ToUInt32(arr, i);
Console.WriteLine("\nमान = " + arr[i]);
Console.WriteLine("परिणाम = " + res);
}
}
}
आउटपुट
बाइट ऐरे... 0 3 5 10 15 2 बाइट ऐरे (स्ट्रिंग प्रतिनिधित्व) = 00-03-05-0A-0F-02 मान = 3 परिणाम = 252314883
उदाहरण
using System;
public class Demo {
public static void Main() {
byte[] arr = { 0, 0, 1, 3, 5, 7, 9, 11, 15 };
int count = arr.Length;
Console.Write("बाइट ऐरे... ");
for (int i = 0; i < count; i++) {
Console.Write("\n" + arr[i]);
}
Console.WriteLine("\n\nबाइट ऐरे (स्ट्रिंग प्रतिनिधित्व) = {0} ",
BitConverter.ToString(arr));
for (int i = 1; i < arr.Length - 1; i = i + 4) {
uint res = BitConverter.ToUInt32(arr, i);
Console.WriteLine("\nमान = " + arr[i]);
Console.WriteLine("परिणाम = " + res);
}
}
}
आउटपुट
बाइट ऐरे... 0 0 1 3 5 7 9 11 15 बाइट ऐरे (स्ट्रिंग प्रतिनिधित्व) = 00-00-01-03-05-07-09-0B-0F मान = 0 परिणाम = 84082944 मान = 7 परिणाम = 252381447