I'm trying to teach myself Visual C# .NET (2003) using a book. One of the early chapters has this exercise:
"Create a project with a form and a text box. Add code to the TextChanged event to cause a recursion when the user types in text. (Hint: Concatenate a character to the end of the user's text using a statement such as this:
txtMyTextBox.Text = String.Concat (this.txtMyTextBox.Text, "a"); )"
If I just add in that code, of course I get an endless loop. So I thought I'd add a Count so it would only add the "a" once. I added this code:
private void H4Ex2txtBox_TextChanged(object sender, System.EventArgs e)
{
//This adds "a" after every text change.
//The count keeps the recursion finite.
const int AddA = 1;
for (int intIndex=0; intIndex < AddA.Count; intIndex++)
H4Ex2txtBox.Text = String.Concat(this. H4Ex2txtBox.Text,"a");
}
I get this error: 'int' does not contain a definition for 'Count'
I figure I'm declaring the constant incorrectly, but I'm just not sure what to do differently.
"Create a project with a form and a text box. Add code to the TextChanged event to cause a recursion when the user types in text. (Hint: Concatenate a character to the end of the user's text using a statement such as this:
txtMyTextBox.Text = String.Concat (this.txtMyTextBox.Text, "a"); )"
If I just add in that code, of course I get an endless loop. So I thought I'd add a Count so it would only add the "a" once. I added this code:
private void H4Ex2txtBox_TextChanged(object sender, System.EventArgs e)
{
//This adds "a" after every text change.
//The count keeps the recursion finite.
const int AddA = 1;
for (int intIndex=0; intIndex < AddA.Count; intIndex++)
H4Ex2txtBox.Text = String.Concat(this. H4Ex2txtBox.Text,"a");
}
I get this error: 'int' does not contain a definition for 'Count'
I figure I'm declaring the constant incorrectly, but I'm just not sure what to do differently.