You can define function like this :
public int Test(params object[] r)
{
//Your Code
return 0;
}
문제
I need to define a function that get some control and do some proccess on them but these control not specified for example these are can be 2 or 4 or 9 or ...
Is any way for define a function that get Dynamic parameter?
해결책
You can define function like this :
public int Test(params object[] r)
{
//Your Code
return 0;
}
다른 팁
you can use params keyword:
void Function_Name(params Control[] controls)
{ }
Then
Function_Name(textBox1);
Or
Function_Name(textBox1, textBox2);
Or
Function_Name(textBox1, textBox2, texBox3);
Or ...
You may use this as input parameter:
params
object[] input
for anything, or this:
params Control[] input
for Control
(as user2864740 said).