C# BinaryWriter - and endianness

Viewed 9078

I am using BinaryWriter in my code, here is my code:

static void Main(string[] args)
{
    FileInfo file = new FileInfo(@"F:\testfile");
    if (file.Exists) file.Delete();
    using (BinaryWriter bw = new BinaryWriter(file.Create()))
    {
        ushort a = 1024;
        ushort b = 2048;
        bw.Write(a);
        bw.Write(b);
        bw.Write(a);
        bw.Write(b);
    }
    Console.ReadLine();
}

But the hex of the output file is :

enter image description here

enter image description here

Isn't that 0x0004 = 4? why?

3 Answers
Related