Question

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?

Was it helpful?

Solution

You can define function like this :

public int Test(params object[] r)
        {
           //Your Code
            return 0;
        }

OTHER TIPS

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:

paramsobject[] input

for anything, or this:

params Control[] input

for Control (as user2864740 said).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top