Windows Forms errors

I'm making a hangman game, this is the part where i grab the letter i've typed in and compare the word and the letter to see if the letter is in the word, this is not the problem because it already works. The problem is that when the letter is in the word it's supposed to replace the _ in lblUnderscores at [i] but i keep getting those errors:
error C3070: 'System::String::default': property does not have a 'set' method
error C2661: 'System::Windows::Forms::Control::Text::set' : no overloaded
function takes 2 arguments

All those errors occurs on the line where i type
lblUnderscores->Text[i]=letter[0]

Do you have any suggestions?

1
2
3
4
5
6
7
        String^ word = lblWord->Text;
        int wordlength = word->Length;
	String^ letter = tbxLetter->Text;

	for (int i =0; i<wordlength; i++){
				 if (letter[0] == word[i]){
					 lblUnderscores->Text[i]=letter[0];


Ord do you have any other idea on how to execute this?
Last edited on
As far as I know objects of type System.String are not mutable. You need to use StringBuilder to build a new string.
How do i use this "StringBuilder" in this case?
Topic archived. No new replies allowed.