C# BitConverter ToUInt32

Description

BitConverter ToUInt32 returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.

Syntax

BitConverter.ToUInt32 has the following syntax.


[CLSCompliantAttribute(false)]/* ww w.  jav a2s  .c  o  m*/
public static uint ToUInt32(
  byte[] value,
  int startIndex
)

Parameters

BitConverter.ToUInt32 has the following parameters.

  • value - An array of bytes.
  • startIndex - The starting position within value.

Returns

BitConverter.ToUInt32 method returns A 32-bit unsigned integer formed by four bytes beginning at startIndex.

Example

The following code example converts elements of Byte arrays to UInt32 values with the ToUInt32 method.


using System;/*from   w  w w.j  a v a 2s. c  om*/

class BytesToUInt32Demo
{

    public static void Main( )
    {
        byte[ ] bytes = {
             15,   0,   0,   0,   0,  16,   0, 255,   3,   0, 
              0, 202, 154,  59, 255, 255, 255, 255, 127 };
        uint value = BitConverter.ToUInt32( bytes, 6 );
        Console.WriteLine(value );
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version