1
Answer

C# console hangman

Ask a question
Christina

Christina

14y
7.6k
1
Hi,

   I am making a simple console hangman game.  I got it to where the user can type a word, but I am having trouble getting the word and replacing it with underscores.

Example the user types family then my program get the word family and  only displays _ _ _ _ _ _  on the screen for the user to start guessing the word.


Thanks Mathew, that is what I am looking for.. 


Here is some of my code:
{
    class Program
    {
        static void Main(string[] args)
        {
            string secretWord;

            

            Console.WriteLine("Welcome to Hangman, Let's Play.");
            Console.WriteLine("");
            Console.WriteLine("Please Type Your Secret Word");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.ReadLine();

THIS IS WHERE I can't figure out how to get the user's word and change it to underscores....      Please Help

            for (int i = 0; i < (secretWord.Length); i++)
            {
                secretWord.Replace(secretWord, ("_"));
                Console.ReadLine();
            }

        
        }
    }
}

The user types the secret word, then my program takes the word and only displays the underscore to equal the number of letters in that word.
Hope this helps on what I want it to do.....

Answers (1)