BinaryReader.ReadChar() : BinaryReader « System.IO « C# / C Sharp by API






BinaryReader.ReadChar()

 

using System;
using System.IO;

class MainClass {
    static void Main() {
        using (FileStream fs = new FileStream("test.bin", FileMode.Create)) {
            using (BinaryWriter w = new BinaryWriter(fs)) {
                w.Write(124.23M);
                w.Write("Tstring");
                w.Write("Tstring 2");
                w.Write('!');
            }
        }
        Console.WriteLine("Press Enter to read the information.");
        Console.ReadLine();

        using (FileStream fs = new FileStream("test.bin", FileMode.Open)) {
            using (StreamReader sr = new StreamReader(fs)) {
                Console.WriteLine(sr.ReadToEnd());
                Console.WriteLine();

                fs.Position = 0;
                using (BinaryReader br = new BinaryReader(fs)) {
                    Console.WriteLine(br.ReadDecimal());
                    Console.WriteLine(br.ReadString());
                    Console.WriteLine(br.ReadString());
                    Console.WriteLine(br.ReadChar());
                }
            }
        }
    }
}

   
  








Related examples in the same category

1.new BinaryReader(FileStream fs)
2.BinaryReader.BaseStream
3.BinaryReader.PeekChar()
4.BinaryReader.ReadByte()
5.BinaryReader.ReadDecimal()
6.BinaryReader.ReadDouble()
7.BinaryReader.ReadInt32()
8.BinaryReader.ReadString()