简体   繁体   中英

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.

From MSDN ( https://docs.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM