dotnet / dotnet/vblang

[Proposal] Allow Select Case to compare Object references

Open
#568 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

This Code gives me a runtime exception, as it is assumed to use `=` in comparing the objects:
```VB.NET
Select Case e.OriginalSource
Case Me, Me.TexTBox
cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
End Select
```

So, this is Ok, but at least allow us to use `Is`. It is already used in some cases like `Case Is < 10`, but the next code is not accepted, and I think it should be:
```VB.NET
Select Case e.OriginalSource
Case Is Me, Is Me.TexTBox
cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
End Select
```

The only valid way is:
```VB.NET
Select Case e.OriginalSource.GetType
Case Me.GetType, Me.TexTBox.GetType
cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
End Select
```

Which is verbose and involving calling three methods!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.