This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
So, I have this bit of code that I'm working on, and in the loop, if I type "y" to have another drink, I want the loop to ask me if I want another drink again until I type "n" would I use "continue" for this like shown in the picture, or would I do that another way?
bool drink = true;
while (drink == true) {
Console.WriteLine("Would you like to take a drink? (y or n)");
string answer = Console.ReadLine();
if (answer == "y") {
continue;
else if (answer == "n") {
drink = false;
}
}
Console.WriteLine("You stopped drinking");
Subreddit
Post Details
- Posted
- 6 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...