foreach (Control c in this.Controls) { if (c is TextBox) { ((TextBox)c).Clear(); } else if(c is Label) { ~~~~~~ } }