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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top