Convert a byte array to a bool and display : BitConverter « Development « C# / CSharp Tutorial






using System;
using System.IO;
 
class MainClass
{
    public static void Main() 
    {
        byte[] b = null;

        
        b = BitConverter.GetBytes(true);

        Console.WriteLine(BitConverter.ToBoolean(b,0));


    }
}
True








14.19.BitConverter
14.19.1.BitConverter
14.19.2.Convert a bool to a byte array and display
14.19.3.Convert a byte array to a bool and display
14.19.4.Convert an int to a byte array and display
14.19.5.Convert a byte array to an int and display
14.19.6.Convert different data types to byte array and convert byte array back