public class TempTest {
public int funcWithParamsArray(int i, params int[] paramsArray) {
return i + paramsArray[0];
}
public void foo() {
// works well
int res = funcWithParamsArray(2, 3);
// error in Consulo, but Visual Studio and Mono compiler accept this
int res1 = funcWithParamsArray(2, paramsArray: 3);
}
}
Ok, I can agree that this may be not a very good practice to write such code, and I don't know what C# specification says about this, but Visual Studio 2015, Rider 2017.3 and Unity's compiler (2017.2.0f3) definitely allow such code, I checked this:
But it would be wrong to write two numbers (like paramsArray: 3, 4), because theyt would be parsed as different arguemnts and cause error (saying that named arguments should not precede positional) in all aforementioned tools, and Consulo does this correctly, too.
Example:
Ok, I can agree that this may be not a very good practice to write such code, and I don't know what C# specification says about this, but Visual Studio 2015, Rider 2017.3 and Unity's compiler (2017.2.0f3) definitely allow such code, I checked this:
But it would be wrong to write two numbers (like
paramsArray: 3, 4
), because theyt would be parsed as different arguemnts and cause error (saying that named arguments should not precede positional) in all aforementioned tools, and Consulo does this correctly, too.