C#C
C#7mo ago
Chroma

Making program run again

How can I make my program run over and over again even if it's done doing it's job? I.e this is my program and the last execution it does, is the if statement. After I have to close the terminal and run it again. I thought with while loop maybe it can work but i didnt get that work

c#
Console.WriteLine("Please type a random word:\t");
String input = Console.ReadLine();
String[] words = {"apple", "car", "basket", "tv"};
Random random = new Random();
int index = random.Next(words.Length);
String randomWord = words[index];
Console.WriteLine(randomWord);
if (input == randomWord) {
    Console.WriteLine("You guessed the word! It was\t" + randomWord);
} else {
    Console.WriteLine("Sorry. The word was:\t" + randomWord);
}
Was this page helpful?