简体   繁体   English

C# 版本 8.. 运算符的优先级是什么?

[英]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.我正在将我们的 MS C# 7.x 解析器升级到 C# 8。它具有新的语法和运算符,其中大多数似乎在任何合理的 V7 语法中都有明显的位置。

However, there is a new binary operator that forms ranges:但是,有一个新的二元运算符 forms 范围:

  ..

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?某处是否有可用的 v8 运算符优先级表?

Apparantly there is no Microsoft-published grammar for version 8. Hoping I'm wrong.显然,没有 Microsoft 发布的版本 8 语法。希望我错了。

From MSDN ( https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/ranges ):从 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.范围运算符的所有 forms 具有相同的优先级。 This new precedence group is lower than the unary operators and higher than the mulitiplicative arithmetic operators.这个新的优先级组低于一元运算符,高于乘法算术运算符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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