Why do `select` and` sub` have parentheses around them in VB Linq expressions?

I converted the following query from C #:

src.Select((c, i) => src.Substring(i)).Count(sub => sub.StartsWith(target)) 

in the VB.NET request:

 src.[Select](Function(c, i) src.Substring(i)).Count(Function([sub]) [sub].StartsWith(target)) 

Using Developer Fusion . I'm just wondering why the version of VB.NET has [] everywhere.

+4
source share
4 answers

select and sub are keywords in VB.NET

+7
source

Sub and Select are keywords in VB.NET, so you must mark them in order to use them as variable names β€” generally using keywords, since variable names should be avoided β€” just rename them and you can get rid of curly braces.

+5
source

The reason that both Select and Sub are reserved words in VB.Net. The environment [] surrounding them is an acceleration mechanism that causes them not to be treated as keywords

+5
source

Little dot: .Select does not need parentheses:

 src.Select(Function(c, i) src.Substring(i)).Count(Function([sub]) [sub].StartsWith(target)) 

works great.

0
source

All Articles