Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Well, I know the basics of code. like how to use Console.WriteLine and ReadLine. I know how to set a string value using console.readline. I've already created a program that asks for a name, gender and age and then displays it. But what I really want to know is how to make a program that tells you something like "What's the magic word?" And you have to guess. And I want to use a bool value to detect if a certain word is typed like "strawberry" and then it tells you a password to an account or something like that.
But when I tried to search it and find a tutorial on it, there was nothing. Absolutely nothing. It all had complicated crap like the bool of c<}|£\€\$/9!$299 is not then do $:()|\|*]!|+ and stuff like that. if you know anywhere where I can find a tutorial to that, please help.
Posted
Updated 14-Oct-13 6:35am
v2
Comments
Abhinav Gauniyal 14-Oct-13 16:32pm    
What do you mean by it: "c<}|£\€\$/9!$299" ?

1 solution

It's not totally clear what your problem is, but does this help?
C#
while (true)
{
    Console.Write("What's the magic word? ");
    string word = Console.ReadLine();
    if (word == "shazam")
    {
    	Console.WriteLine("You guessed it!");
        break;
    }
    else
    {
        Console.WriteLine("Sorry, try again!");
        // you could also add a counter so it terminates
        // the program after a certain number of failures.
    }
}
// user correctly entered the magic word so continue here ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900