Ira Baxter
Ira Baxter

Reputation: 95352

What is the precedence of C# version 8 .. operator?

I'm upgrading our MS C# 7.x parser to C# 8. It has new syntax and operators, and most of these seem to have obvious placements in any reasonable V7 grammar.

However, there is a new binary operator that forms ranges:

  ..

But I can't find any information on where this goes in the operator precedence hierarchy. Realistically one would expect it be lower precedence than addition or subtraction so one could write

xyz[n+k..m-k]

but that's just guessing on my part.

Is there a v8 operator precedence table available somewhere?

Apparantly there is no Microsoft-published grammar for version 8. Hoping I'm wrong.

Upvotes: 0

Views: 184

Answers (1)

Manfred Radlwimmer
Manfred Radlwimmer

Reputation: 13394

From MSDN (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/ranges):

All forms of the range operator have the same precedence. This new precedence group is lower than the unary operators and higher than the mulitiplicative arithmetic operators.

Upvotes: 4

Related Questions