public static void SbmMasa() { bool r = true; while (r) { Console.ForegroundColor = ConsoleColor.Green; sbyte[] a = new sbyte[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Console.WriteLine("Comandos disponibles:\n{0}: Conversor Kilogramos.\n{1}: Conversor Gramos.", a[0], a[1]); Console.WriteLine("{0}: Conversor Toneladas (métricas).\n{1}: Conversor Toneladas Cortas.\n{2}: Conversor Toneladas Largas", a[2], a[3], a[4]); Console.WriteLine("{0}: Conversor Libras.\n{1}: Conversor Onzas.\n{2}: Conversor \"Stones\".", a[5], a[6], a[7]); Console.WriteLine("{0}: Volver al menú.", a[8]); sbyte i = 1; try { Console.Write(">> "); i = Convert.ToSByte(Console.ReadLine()); } catch (Exception e) when(e.GetType() != typeof(FormatException)) { Console.WriteLine(e.Message); } catch (FormatException e) { Console.WriteLine("El valor introducizo no es numérico."); Console.WriteLine(e.Message); } finally { if (i == a[0]) { Transformador.CmdKg(); r = true; } else if (i == a[1]) { Transformador.CmdGr(); r = true; } else if (i == a[2]) { Transformador.CmdT(); r = true; } else if (i == a[3]) { Transformador.CmdUsT(); r = true; } else if (i == a[4]) { Transformador.CmdUkT(); r = true; } else if (i == a[5]) { Transformador.CmdLb(); r = true; } else if (i == a[6]) { Transformador.CmdOz(); r = true; } else if (i == a[7]) { Transformador.CmdSt(); r = true; } else if (i == a[8]) { r = false; Console.Clear(); } else { Console.WriteLine("Comando no encontrado."); r = true; } } } }