Convert byte value to its base 2(Binary), base 8(Octal) and base 16(Hex) forms
using System;
public class Example
{
public static void Main()
{
byte[] numbers ={ 0, 15, 100, 213 };
Console.WriteLine("{0} {1,8} {2,5} {3,5}","Value", "Binary", "Octal", "Hex");
foreach (byte number in numbers) {
Console.WriteLine("{0,5} {1,8} {2,5} {3,5}",
number, Convert.ToString(number, 2),
Convert.ToString(number, 8),
Convert.ToString(number, 16));
}
}
}
Related examples in the same category