Life is short
def foo(b,a,r):
# bla bla bla
pass
mylist = ['b','a','r']
foo(*mylist)
That's how passing a list of arguments into method multiple positional parameters in Python.
But in C# I found out passing an array into a parameter of array using the params keywords, like this one:
void foo(params string[] bar)
{
// bla bla bla
}
string[] mylist = {"b", "a", "r"};
foo(mylist)
Imagine how If I cannot touch the function, is there an easier way Is there a way to do that?
Here is what I mean:
void foo (string b, string a, string r)
{
// bla bla bla
}
string[] mylist = {"b", "a", "r"};
foo(mylist[0],mylist[1],mylist[2]); // This line makes my life difficult
I search online and can't found an alternative of it. Just want to make sure that I didn't miss the hidden feature that C# provide. Who know there's such shortcut for us?
paramswould be the solution, ruling that out puts C# at an unfair disadvantage ;-)