Mixing and named parameters in C #: why is it necessary to specify the desired parameter?

Short version . The named argument following the argument outgives a compiler error, but I cannot find support for this behavior in the language specification.

Long version :

I use an overload of three parameters Enum.TryParse<TEnum>, but I would prefer to name the parameter ignoreCaseto make my code more understandable, for example:

MyEnum res;
b = Enum.TryParse<MyEnum>(inputString, true, out res);

leaves the boolean value fuzzy (if this method is not known 1 ). Therefore, I would like to use:

b = Enum.TryParse<MyEnum>(inputString, out res, ignoreCase: true);

However, the compiler reports this as an error:

The named argument 'ignoreCase' indicates a parameter for which a positional argument has already been specified.

IDE ignoreCase. VS2010 .NET 4 VS11 Beta 4 4,5 . out .

b = Enum.TryParse<MyEnum>(inputString, result: out res, ignoreCase: true);

( ) 2 , : : out, .

& section; 7.5.1. #. : 4.0, , , out, , . , , : , ignoreCase.

? ?


1 , enum.

2 : :

private static void TestMethod(int one, float two, out string three) {
  three = "3333";
}

, out:

TestMethod(1, out aString, two: 1.0f);
+5
2

"" .

value ignoreCase, ignoreCase .
out.

, , .

+6

positional , , , , , .

, :

b = Enum.TryParse<MyEnum>(inputString, out res, ignoreCase: true);

out res ignoreCase, , . , , , out res ignoreCase.

, "" ignoreCase , out res.

+3

All Articles