Question

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)

Was it helpful?

Solution

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.

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top