Array.ToString() returning System.Char[] c#

前端 未结 4 1164
孤城傲影
孤城傲影 2020-12-11 21:09

Im making a hangman game, at the start of the game the word that the player must guess is printed as stars. I have just started making it again after attempting to write it

4条回答
  •  难免孤独
    2020-12-11 22:00

    The variable stars is an array of chars. This is the reason you get this error. As it is stated in MSDN

    Returns a string that represents the current object.

    In order you get a string from the characters in this array, you could use this:

     Console.Write("Word to Guess: {0}" , new String(stars));
    

提交回复
热议问题