C Sharp BinaryWriter

C# BinaryWriter

Found in System.IO namespace, the C# BinaryWriter class supports specific encoding for writing a string and is thus used for writing the binary information into a stream.

Example:

using System;  
using System.IO;  
namespace Example  
{  
    class content  
    {  
        static void Main(string[] args)  
        {  
            string fileName = "d\\bfile.dat";  
            using (BinaryWriter bw = new BinaryWriter(File.Open(fileName, FileMode.Create)))  
            {  
                bw.Write(true);  
                bw.Write("Hello World");  
                bw.Write(1);  
            }  
            Console.WriteLine("Success!!");    
        }  
    }  
}

Console Output:

D\\bfile.dat:

Explanation:

In the above example, we are using the BinaryWriter class to write data into a .dat file.

Please follow and like us:
Content Protection by DMCA.com
togel situs toto situs togel situs toto situs toto agen togel situs togel situs togel togel situs togel resmi situs togel situs togel situs toto link togel togel online