Q:

C# Iterating over known textboxes from array

I am trying to iterate over textboxes from a string in string Array
static string[] TextBoxes = {
                             "EmpName",
                             "Sales",
                             "BasePay",
                             "Commission",
                             "GrossPay",
                             "Deductions",
                             "Housing",
                             "FoodAndClothing",
                             "Entertainment",
                             "Misc"
                            };

Each of the above are parts of the form for example txtHousing is the housing input element. And so on and so forth.
And the iteration takes place here
private void btnClear_Click(object sender, EventArgs e)
{
    for (byte i = 0; i < TextBoxes.Length; i++)
    {
        this["txt" + TextBoxes[i]].Text = "";
    }
    this.txtEmpName.Focus();
}

Except I'm getting a strange "error" for this System.String can we not call objects like this from the this object?
Just read a source saying that this.getProperty may work so I'll try that.
Error
Cannot apply indexing with [] to an expression of type 'Pay_Calculator.PayCalculator' 

A:

One solution is to use Reflection/Dynamic object.
var me = (dynamic) this;
foreach (var name in TextBoxes)
{
  ((TextBox) me['txt' + name]).Value = string.Empty;
}

Another solution is to recurse over all controls, then you don't need to name all the text boxes.
private void btnClear_Click(object sender, EventArgs e)
{
   ClearTextBox(this);
}

void ClearTextBox (Control c)
{
    var t = c as Textbox;
    if (t != null)
       t.Value = string.Empty;
    foreach (var child in c.Controls)
       ClearTextBox(child);
}

