Creating methods with infinite overloads ? (.NET)

Posted by MarceloRamires on Stack Overflow See other posts from Stack Overflow or by MarceloRamires
Published on 2010-03-12T20:44:36Z Indexed on 2010/03/12 20:47 UTC
Read the original article Hit count: 144

Filed under:
|
|
|

In C# you can do this:

foo = string.Format("{0} {1} {2} {3} ...", "aa", "bb", "cc" ...);

This method Format() accepts infinite parameters, being the first one how the string should be formatted and the rest are values to be put in the string.

Today I've come to a situation where I had to get a set of strings and test them, then I remembered this language functionality, but I had no clue. After a few unsuccessful web searches, I've realised it would be more prudent to just get an array, which didn't make me quite satisfied.

Q: How do I make a function that accepts infinite parameters? And how do I use it ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about function