Ask if you want to enter another data in c # (do ... while) [closed]

1

Ask the user from the console, when you finish entering data, ask if you want to enter another data, when answering that "si" repeats the cycle.

    
asked by ISC.Villegas 20.06.2017 в 19:55
source

2 answers

1

Before the cycle declares a pair of variables, a string that takes the answer and a bool that takes the yes.

bool bandera = false;
string respuesta;
do{

//Lo que necesitas en tu ciclo
bandera = true;
Console.WriteLine("¿Desea algún dato nuevo? Si/No");
respuesta = Console.ReadLine();
if(respuesta.ToLower().Equals("si")) bandera = false;
}while(bandera);

The do while will run while you answer if

    
answered by 20.06.2017 / 20:06
source
0

Here you can giarte with something like this.

  public void Add()
  {
         Console.WriteLine("Introduzca un texto");
         String texto;
         texto=Console.ReadLine();
         Console.WriteLine("El texto introducido es: " + texto);

        Console.WriteLine("Desea introducir otro texto");
         String Opcion;
         Opcion=Console.ReadLine();
         if(Opcion == "Si")
         { 
             Add();
         }
  }
    
answered by 20.06.2017 в 20:05