使用console.readline为数组c中的索引赋值

时间:2015-06-03 22:09:40

标签: c# arrays

我正在制作一个刽子手游戏,我希望能够从控制台获取用户输入并将其分配给数组中的值。

string hangWord;
char[] hangArray;

console.WriteLine("Please enter your hangman word.");
hangWord = console.Readline();
char[] hangArray = {hangWord}

如何做到这一点,以便用户输入像"淋浴" 索引将是     hangArray [] = {" s"," h"," o"," w"," e", " R"}; 自动?

1 个答案:

答案 0 :(得分:1)

char[] hangArray = hangWord.ToCharArray()