static void Main(string[] args) { Console.WriteLine(DecimalConversion.ConvertToBase8(420)); Console.WriteLine(DecimalConversion.ConvertToBase2(420)); Console.WriteLine(BinaryConversion.ConvertToBase10("111111111111111111")); Console.WriteLine(BinaryConversion.ConvertToBase8("111111111111111111")); Console.WriteLine(OctalConversion.ConvertToBase2("345")); Console.WriteLine(OctalConversion.ConvertToBase10("345")); }
public static string ConvertToBase2(string s) { string result = ""; for (int i = 0; i < s.Length; i++) { int t = int.Parse(s[i].ToString()); result += DecimalConversion.ConvertToBase2(t); } return(Util.NormalizeOctal(result)); }
static void Main(string[] args) { Console.WriteLine(DecimalConversion.ConvertToBase8(130)); Console.WriteLine(DecimalConversion.ConvertToBase2(260)); Console.WriteLine(BinaryConversion.ConvertToBase10("11111100011111111")); Console.WriteLine(BinaryConversion.ConvertToBase8("110111111101111111")); Console.WriteLine(OctalConversion.ConvertToBase2("369")); Console.WriteLine(OctalConversion.ConvertToBase10("360")); Console.WriteLine("\n\nTo change the numbers to be converted, reference and edit Program.cs"); }