// FUNCIÓN QUE DEVUELVE UN STRING (CUALQUIER COSA) QUE NO ESTE VACIO PEDIDO POR TECLADO // MOSTRANDO UN MENSAJE PERSONALIZADO POR PANTALLA // @param - string: un mensaje para mostrar por pantalla public static string leerCadena(string msg) { bool salir = false; string aux = null; do { Console.Write("?> " + msg + ": "); aux = Console.ReadLine(); if ((String.IsNullOrEmpty(aux))) { CH.lcdColor("!> ¿¡Perdona!?... ?@#!!", ConsoleColor.Red); } else { salir = true; } } while (!salir); return(aux); }
// FUNCIÓN DE DEVUELVE UN STRING (NO NUMERO REAL) PEDIDO POR TECLADO // @param - string: el mensaje a mostrar // @return - string: el string introducido public static string leerString(string msg) { bool salir = false; string aux = null; int numero = 0; do { Console.Write("?> " + msg + ": "); aux = Console.ReadLine(); if ((String.IsNullOrEmpty(aux)) || (Int32.TryParse(aux, out numero))) { CH.lcdColor("!> ¿¡Perdona!?... ?@#!!", ConsoleColor.Red); } else { salir = true; } } while (!salir); return(aux); }
public static string leerDni() { bool salir = false; string aux = null; int opcion = 0; do { Console.Write("?> DNI DEL CLIENTE...: "); aux = Console.ReadLine(); if (!Int32.TryParse(aux, out opcion) && aux != "") { salir = true; } else { CH.lcdColor("!> ¿¡Perdona!?... ?@#!!", ConsoleColor.Red); } } while (!salir); return(aux); }