Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 707
chiccodoro Avatar asked Mar 26 '13 10:03

chiccodoro


3 Answers

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.

like image 172
dtb Avatar answered Nov 15 '22 06:11

dtb


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

like image 24
MarcinJuraszek Avatar answered Nov 15 '22 06:11

MarcinJuraszek


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.

like image 23
Darren Avatar answered Nov 15 '22 05:11

Darren