C# BinaryReader ReadUInt32

Description

BinaryReader ReadUInt32 Reads a 4-byte unsigned integer from the current stream and advances the position of the stream by four bytes.

Syntax

BinaryReader.ReadUInt32 has the following syntax.


[CLSCompliantAttribute(false)]
public virtual uint ReadUInt32()

Returns

BinaryReader.ReadUInt32 method returns A 4-byte unsigned integer read from this stream.

Example


using System;// w  w w .ja  v a  2 s .c  o m
using System.IO;

class ConsoleApplication
{
    const string fileName = "data.dat";

    static void Main()
    {
        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            writer.Write((UInt32)123);
        }
        using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
        {
            Console.WriteLine(reader.ReadUInt32());
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter