Using Binary Writer Class the Contents are Written
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Program to Demonstrate Binary Writer
C# Program to Demonstrate Binary Writer
This is a C# Program to illustrate binary writer.
This C# Program Illustrates Binary Writer.
Here Write method writes a Boolean value to the stream as a one-byte value.
Here is source code of the C# Program to Illustrate Binary Writer. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Illustrate Binary Writer */ using System; using System.IO; class ConsoleApplication { const string fileName = "program.dat"; static void Main() { Write(); Console.WriteLine("Using Binary Writer Class the Contents are Written "); } public static void Write() { using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create))) { writer.Write(1.250F); writer.Write(@"c:\Temp"); } } }
This C# program is used to illustrate binary writer. Using binary writer class the contents are written in the file. The BinaryWriter class provides methods that simplify writing primitive data types to a stream. The write() method is used to write a Boolean value to the stream as a one-byte value.
The class includes write methods that support different data types while creating a new instance of the BinaryWriter class. Provide the stream to write to, and optionally specify the type of encoding and whether to leave the stream open after disposing the BinaryWriter object. If the encoding type didn’t specified, UTF-8 is used.