【发布时间】:2021-05-30 14:59:54
【问题描述】:
我已经声明了一个这样的类:
public class Cell : IEquatable<Cell>
{
public int id { get; }
public SetOfCells group;
}
而且每次我想使用group,Rider 都会在前面加上@,像这样:
foreach (Cell cell in c1.@group) {
/* blabla */
}
精度:c1.@group 和 c1.group 两者都有效。这是为什么呢?
(如果你能告诉我正确的词来谷歌找到我感兴趣的有价值的答案,因为我找不到:“csharp property +"@" 没有帮助......”)
【问题讨论】:
-
我觉得这是 Rider 特有的一种奇怪行为,因为在 Visual Studio 中,它不会检测到
group关键字的特定用法。必须在 LINQ 查询中使用它才能将其检测为关键字。 -
@OlivierPons 在 C# 中这样使用的
@字符称为“逐字标识符”或“逐字前缀”:docs.microsoft.com/en-us/dotnet/csharp/language-reference/…