How do I return back to the start of the switch case after inputting value? C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I return back to the start of the switch case after inputting value? C#

https://code.sololearn.com/cE3QxkfibV38/?ref=app I am currently working on a login project and I am new to C#. In my project, I entered an input of 5 different usernames/passwords into an array before starting the switch case which I have used as a menu option. If you see case 2: I want to be able to return back to the start of the switch case after inputting the value but I do not know how to do this or if this is possible. Does anyone know if this is possible? I have insert a comment in the code where I would like to return back to the start of the switch case. case 2: Console.WriteLine("-----PASSWORD RECOVERY-----\n"); Console.WriteLine("Please input your username: "); string Username1 = Console.ReadLine(); Console.Clear(); bool exitU1 = false; for (i = 0; i < ForUser.Length; i++) { if (Username1 == ForUser[i]) { exitU1 = true; } } if (exitU1) { Console.WriteLine("-----PASSWORD RECOVERY-----\n"); Console.WriteLine("Please input your new password: "); ForPass[i] = Console.ReadLine(); //HERE IS WHERE I WANT TO RETURN BACK TO THE START OF THE SWITCH CASE } else { Console.WriteLine("USERNAME NOT FOUND!"); } break;

14th Nov 2022, 5:31 PM
Liam
1 Answer
+ 2
writer whole block of statements to be repeated inside an infinite loop
14th Nov 2022, 5:56 PM
I am offline
I am offline - avatar