params

  • Thread starter Thread starter Kevin Jackson
  • Start date Start date
K

Kevin Jackson

What's the difference between

public void Foo(string s, object [] o)

and

public void Foo(string s, params object [] o)

?
 
Kevin said:
What's the difference between

public void Foo(string s, object [] o)

and

public void Foo(string s, params object [] o)

When using the params keyword, you can pass in an arbitrary number of
arguments at that point when calling the method. The compiler will
handle packaging them in an array.

If you don't use the params keyword, you must pass in an actual array -
no help from the compiler here.
 
Got'cha... I should of studied the help example a little more :)

Thanks

mikeb said:
Kevin said:
What's the difference between

public void Foo(string s, object [] o)

and

public void Foo(string s, params object [] o)

When using the params keyword, you can pass in an arbitrary number of
arguments at that point when calling the method. The compiler will
handle packaging them in an array.

If you don't use the params keyword, you must pass in an actual array -
no help from the compiler here.
 
Back
Top