문제

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:

paramsobject[] input

for anything, or this:

params Control[] input

for Control (as user2864740 said).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top