C# Moving around the script
Hi
I am a C# noob, most of the things i know about it i have asked on Icrontic. I want to find a way to go to another part in the script.
for example
System.Console.Out.WriteLine("do you want to exit");
string1 = System.Console.In.ReadLine();
if (string1.ToLower().Contains"yes"))
{
//here it would go to the end
}
else
//here it would continue the script
or if it goes back
System.Console.Out.WriteLine("hello");
System.Console.Out.WriteLine("do you want me to repeat that");
string1 = System.Console.In.ReadLine();
if (string1.ToLower().Contains"yes"))
{
//here it would go back
}
else
//here it would continue the script
is this possible? and if so how?
I am a C# noob, most of the things i know about it i have asked on Icrontic. I want to find a way to go to another part in the script.
for example
System.Console.Out.WriteLine("do you want to exit");
string1 = System.Console.In.ReadLine();
if (string1.ToLower().Contains"yes"))
{
//here it would go to the end
}
else
//here it would continue the script
or if it goes back
System.Console.Out.WriteLine("hello");
System.Console.Out.WriteLine("do you want me to repeat that");
string1 = System.Console.In.ReadLine();
if (string1.ToLower().Contains"yes"))
{
//here it would go back
}
else
//here it would continue the script
is this possible? and if so how?
0
Comments
This is just one of many ways to achieve this sort of looping.
the error underline appears under everywhere where i have written continue
Then replace "while(continue)" with "while(keepGoing)"
Also, I just realized that I forgot to change the value of sentinel (keepGoing in this case) to false at some point so it doesn't keep looping. So inside the else{} make the first line "keepGoing = false;"
thankyou
:-)
but now when i have
_______________________________
if (string1.ToLower().Contains("yes"))
{
keepgoing;
}
_______________________________
the word keepgoing becomese underlined
thanks very much
:-)