Технически, вы можете переместить инициализацию в конструктор :
public partial class Form1: Form {
...
List<string> words = new List<string>();
List<string> guessedLetters = new List<string>();
string word;
// Turning word into char array
char[] letters;
public Form1() {
word = "sword";
letters = word.ToCharArray();
}
}
Другая возможность - объявить свойство: когда вы хотите, чтобы word
разбилось на буквы, просто вызовите letters
собственность
public partial class Form1: Form {
...
List<string> words = new List<string>();
List<string> guessedLetters = new List<string>();
string word = "sword";
...
private char[] letters {
get {
return null == word
? new char[0]
: word.ToCharArray();
}
}