C# BinaryWriter Write(UInt32)

Description

BinaryWriter Write(UInt32) Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.

Syntax

BinaryWriter.Write(UInt32) has the following syntax.


[CLSCompliantAttribute(false)]
public virtual void Write(
  uint value
)

Parameters

BinaryWriter.Write(UInt32) has the following parameters.

  • value - The four-byte unsigned integer to write.

Returns

BinaryWriter.Write(UInt32) method returns

Example


using System;//from  w w w . j  a  v  a  2  s .  c  om
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