Converts int to string in a specified base.
using System;
using System.Globalization;
public class MainClass
{
public static void Main()
{
int[] bases = { 2, 8, 10, 16};
byte[] numbers = { 0, 12, 113, Byte.MaxValue};
foreach (int baseValue in bases)
{
Console.WriteLine("Base {0} conversion:", baseValue);
foreach (byte number in numbers)
{
Console.WriteLine("{0,-5} --> 0x{1}",number, Convert.ToString(number, baseValue));
}
}
}
}
Related examples in the same category