static void Main() { Console.WriteLine("Enter the numeral base of the your number (2, 10 or 16): "); int numBase = int.Parse(Console.ReadLine()); Console.WriteLine("and numeral base in which you want your number to be converted (2, 10 or 16): "); int newBase = int.Parse(Console.ReadLine()); while (numBase == newBase) { Console.WriteLine("Incorrect input! Equal numeral systems!"); Console.WriteLine("Enter the numeral base of the first number (2, 10 or 16): "); numBase = int.Parse(Console.ReadLine()); Console.WriteLine("and numeral base of the second number (2, 10 or 16): "); newBase = int.Parse(Console.ReadLine()); } if (numBase == 10 && newBase == 2) { ConvertDecimal.Main(); } if (numBase == 2 && newBase == 10) { BinToDec.Main(); } if (numBase == 10 && newBase == 16) { DecToHex.Main(); } if (numBase == 16 && newBase == 10) { HexToDec.Main(); } if (numBase == 16 && newBase == 2) { HexToBin.Main(); } if (numBase == 2 && newBase == 16) { BinToHex.Main(); } }
static void Main() { Console.WriteLine("1. Decimal to Binary"); Console.WriteLine("2. Binary to Decimal"); Console.WriteLine("3. Decimal to Hexadecimal"); Console.WriteLine("4. Hexadecimal to Decimal"); Console.WriteLine("5. Hexadecimal to Bin"); Console.WriteLine("6. Binary to Hexadecimal"); Console.WriteLine("What is your choice ? "); int choice = int.Parse(Console.ReadLine()); if (choice == 1) { DecToBin.Main(); } else if (choice == 2) { BinaryDecimal.Main(); } else if (choice == 3) { DecHex.Main(); } else if (choice == 4) { HexDec.Main(); } else if (choice == 5) { hexadecimal.Main(); } else if (choice == 6) { BinToHex.Main(); } }