Can I implicitly create an array from one single element in C#?
For instance, I have this method
public void MyMethod(string[] arrayString)
At some point in my code I have
string str = "myStr";
MyMethod(str)
Of course the second linhe is an error, because I am passing a string while MyMethod expects a string[].
Is there any clean way to call MyMethod without using
MyMethod(new string[] {str})
If you use a
paramsarray, this will be fine: