I have a lot of code that takes on the following pattern
void Add(int foo)
{
$my question
}
void Add(List<int> bar)
{
//do stuff
}
I was wondering (other than writing an extension method) if there was something ‘shorter than writing:
Add(new List<int>(new int[]{foo}));
everytime I wanted to call the second method. Hoping to find a gem ive missed in the .net library.
If you can modify the second method, it might be better if it was
Then you can call it like
Add(foo, foo2, foo3)orAdd(myList.ToArray())Have a look at the params keyword.