chiccodoro
chiccodoro

Reputation: 14716

Is by a reserved keyword?

I can't find "by" in lists of reserved keywords in C# but the Resharper Visual Studio plug-in seems to consider it being one - it prepends it with a @ escape whenever it generates code (e.g. by executing a refactoring command)

Upvotes: 8

Views: 433

Answers (3)

Darren
Darren

Reputation: 70728

by is not a reserved word it is a query word for using LINQ:

For example:

         (from x in Collection
         group x by n);

You can escape any C# reserved word by using the @ symbol in front of it.

Upvotes: 4

MarcinJuraszek
MarcinJuraszek

Reputation: 125620

by is used within LINQ query syntax. It's reserved only within query syntax context.

Upvotes: 5

dtb
dtb

Reputation: 217293

by is a Query Keyword, i.e., it's a keyword only in certain positions within LINQ Query Expressions, in particular only within a group clause.

The by contextual keyword is used in the group clause in a query expression to specify how the returned items should be grouped.

Upvotes: 14

Related Questions