i'm in a bit of a bind with a problem that's supposed to mediocre, but seemingly i can't implement the solution.
I have buttons, with a single char on each of them, 26 to be exact (english alphabet), When i click any of them, the loop iterates through the string for the text value on the buttons and replaces it with quotation marks.
The code works, and it prints out the newAlphabet without the clicked character. But when i click another button, it returns the newAlphabet albeit with the previously removed character and removes the new clicked character.
The code is as follows
static string alphabet = "abcdefghijklmnopqrstuvwxyz";
static string newAlphabet = string.Empty;
Button tempBtn = (Button)sender;
for (int i = 0; i < alphabet.Length; i++)
{
if (alphabet[i].ToString().Contains(tempBtn.Text))
{
newAlphabet = alphabet.Replace(tempBtn.Text, "");
MessageBox.Show(newAlphabet);
}
}
Sorry for grammar or spelling errors, english is not my first language.
Regards, HC
forloop could be replaced with the single line:newAlphabet = newAlphabet.Replace(tempBtn.Text, "");.