I want to create a method that accepts a "parameterized" input object of type string array of string array. Something like:
public void MyMethod(params string[][] input)
{
//...do stuff
}
I am calling this method as follows:
MyMethod({"arry1-elem1","arry1-elem2"}, {"arry2-elem1","arry2-elem2"}, {"arry3-elem1","arry3-elem2"});
However, when I do this I get the following error:
Invalid expression term '{'
What am I doing wrong here. Is it not possible to input an implicitly typed array as an input?
MyMethod(new string[]{"arry1-elem1","arry1-elem2"}, new string[]{"arry2-elem1","arry2-elem2"}, new string[]{"arry3-elem1","arry3-elem2"});
You aren't declaring their type when you're attempting to pass them in.
Even better, you don't have to say string
:
MyMethod(new[]{"a","b"}, new[]{"c","d"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With