How can i use infinite parameters in a method
-
ok my problem is like this.. i want to make a method for clearing textbox`s in a form and the method looks like this.. public void clearTextBox(TextBox a, TextBox b) { a.Text=""; b.Text=""; } of course it will clear only two textbox`s which i decleared.. but i want my method to clear n textbox so i can use this method several times.. how should the code look like ? i remember from c++ it should be something like this but its not working at c#: public void clearTextBox(TextBox a,...,Textbox b); any help would be great.. thanx guys.. good coding..
-
ok my problem is like this.. i want to make a method for clearing textbox`s in a form and the method looks like this.. public void clearTextBox(TextBox a, TextBox b) { a.Text=""; b.Text=""; } of course it will clear only two textbox`s which i decleared.. but i want my method to clear n textbox so i can use this method several times.. how should the code look like ? i remember from c++ it should be something like this but its not working at c#: public void clearTextBox(TextBox a,...,Textbox b); any help would be great.. thanx guys.. good coding..
void ClearText(params Textbox[] text)
{
foreach (Textbox t in text)
t.Text = "";
}Then, you can call it with any number of arguments: ClearText(TextBox1, TextBox2, TextBox3); I don't see dead pixels anymore... Yes, even I am blogging now! -- modified at 6:59 Saturday 12th November, 2005