Req20: Range expressions

[This post is part of a series, "wish-list for future versions of VB"]

 

IDEA 1: Allow range expressions as a literal for IEnumerable. For instance,

        ' This expression

        Dim x = 5 To 14

        ' should be syntactic sugar for this one

        Dim x = Enumerable.Range(5, 10)

 

IDEA 2: Allow "in range" expressions. For instance,

' These conditions

If y In 50 To 100 Then ...

        If 50 <= y <= 100 Then ...

' should be syntactic sugar for this one

        If 50 <= y AndAlso y <= 100 Then

 

 

Provisional evaluation from VB team: The syntax for IEnumerable.Range isn't much of an improvement. As for the range-expression-tests, "50 <= y <= 100" already has a different meaning in VB, and "y In 50 To 100" isn't any clearer than the long version. We're not persuaded by these ideas.