Using this bit converter, we can convert string, bool and integer
using System;
using System.Collections.Generic;
using System.Text;
namespace file
{
class Program
{
static void Main(string[] args)
{
byte[] b = BitConverter.GetBytes(true);
Console.WriteLine(BitConverter.ToString(b));
Console.WriteLine(BitConverter.ToBoolean(b, 0));
b = BitConverter.GetBytes(3678);
Console.WriteLine(BitConverter.ToString(b));
// Convert a byte array to an int and display.
Console.WriteLine(BitConverter.ToInt32(b, 0));
Console.ReadLine();
}
}
}
OUTPUT
using System;
using System.Collections.Generic;
using System.Text;
namespace file
{
class Program
{
static void Main(string[] args)
{
byte[] b = BitConverter.GetBytes(true);
Console.WriteLine(BitConverter.ToString(b));
Console.WriteLine(BitConverter.ToBoolean(b, 0));
b = BitConverter.GetBytes(3678);
Console.WriteLine(BitConverter.ToString(b));
// Convert a byte array to an int and display.
Console.WriteLine(BitConverter.ToInt32(b, 0));
Console.ReadLine();
}
}
}
OUTPUT