Format byte value to its hexadecimal form
using System;
public class Example
{
public static void Main()
{
byte[] numbers = { 0, 16, 104, 213 };
foreach (byte number in numbers) {
// Display value with hexadecimal.
Console.Write(number.ToString("X2") + " ");
// Display value with four hexadecimal digits.
Console.WriteLine(number.ToString("X4"));
}
}
}
Related examples in the same category