P piotrek Nov 11, 2005 #1 Hi I'd like to ask: How to create function with variable number of parameters? PK
P Peter Rilling Nov 11, 2005 #2 use the "params" keyword in the parameter definition. public void MyMethod( string param1, int param2, params int paramSet)
use the "params" keyword in the parameter definition. public void MyMethod( string param1, int param2, params int paramSet)
M Markus Stoeger Nov 11, 2005 #3 piotrek said: Hi I'd like to ask: How to create function with variable number of parameters? Click to expand... take a look at the "params" keyword: private void button1_Click(object sender, System.EventArgs e) { myfunc(123, "abc", new Point(5, 7)); } private void myfunc(params object[] p) { foreach (object o in p) { Trace.WriteLine(o.ToString()); } }
piotrek said: Hi I'd like to ask: How to create function with variable number of parameters? Click to expand... take a look at the "params" keyword: private void button1_Click(object sender, System.EventArgs e) { myfunc(123, "abc", new Point(5, 7)); } private void myfunc(params object[] p) { foreach (object o in p) { Trace.WriteLine(o.ToString()); } }