C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# BinaryWriterC# BinaryWriter class is used to write binary information into stream. It is found in System.IO namespace. It also supports writing string in specific encoding. C# BinaryWriter ExampleLet's see the simple example of BinaryWriter class which writes data into dat file. using System; using System.IO; namespace BinaryWriterExample { class Program { static void Main(string[] args) { string fileName = "e:\\binaryfile.dat"; using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create))) { writer.Write(2.5); writer.Write("this is string data"); writer.Write(true); } Console.WriteLine("Data written successfully..."); } } } Output: Data written successfully...
Next TopicC# BinaryReader
|