using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace BinaryDecimal_Converter { class Program { static void Main(string[] args) { string binary = "0"; int number = 0, choice; bool errorCheck; Console.WriteLine("1) base10 to base2\n2) base2 to base10\n3) stop"); errorCheck = int.TryParse(Console.ReadLine(), out choice); if (errorCheck) { switch (choice) { case 1: Console.Write("Decimal: "); errorCheck = int.TryParse(Console.ReadLine(), out number); if (errorCheck) { binary = Convert.ToString(number, 2); Console.WriteLine("Binary: {0}", binary); } else Console.WriteLine("Unable to Parse"); break; case 2: Console.Write("Binary: "); errorCheck = int.TryParse(Console.ReadLine(), out number); binary = number.ToString(); if (errorCheck) { number = Convert.ToInt32(binary, 2); Console.WriteLine("Decimal: {0}" , number); } else Console.WriteLine("Unable to Parse"); break; } } else Console.WriteLine("Unable to Parse"); Console.ReadKey(); } } }