কম্পিউটার

C# BitConverter.ToUInt32() পদ্ধতি


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("Byte Array... ");
      for (int i = 0; i < count; i++) {
         Console.Write("\n"+arr[i]);
      }
      Console.WriteLine("\n\nByte Array (String representation) = {0} ",
      BitConverter.ToString(arr));
      for (int i = 1; i < arr.Length - 1; i = i + 4) {
         uint res = BitConverter.ToUInt32(arr, i);
         Console.WriteLine("\nValue = "+arr[i]);
         Console.WriteLine("Result = "+res);
      }
   }
}

আউটপুট

Byte Array...
0
3
5
10
15
2
Byte Array (String representation) = 00-03-05-0A-0F-02
Value = 3
Result = 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("Byte Array... ");
      for (int i = 0; i < count; i++) {
         Console.Write("\n"+arr[i]);
      }
      Console.WriteLine("\n\nByte Array (String representation) = {0} ",
      BitConverter.ToString(arr));
      for (int i = 1; i < arr.Length - 1; i = i + 4) {
         uint res = BitConverter.ToUInt32(arr, i);
         Console.WriteLine("\nValue = "+arr[i]);
         Console.WriteLine("Result = "+res);
      }
   }
}

আউটপুট

Byte Array...
0
0
1
3
5
7
9
11
15
Byte Array (String representation) = 00-00-01-03-05-07-09-0B-0F
Value = 0
Result = 84082944
Value = 7
Result = 252381447

  1. C# এ Array.ConstrainedCopy() পদ্ধতি

  2. C# এ পদ্ধতি এড়িয়ে যান

  3. C# এ Array.BinarySearch পদ্ধতি

  4. C# এ ক্লোন() পদ্ধতি