dotnet / dotnet/vblang

Allow using IEqualityComparer(Of T) in Select...Case-Statements

Open
#123 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

If someone wants to match a string case-insensitive in a `Select`-Statement, he is more or less forced to convert the string to lower or upper case.

```
Select Case tagName.ToLower()
Case "a"
Case "p"
Case else
End Select
```

The .NET-Framework offers the` IEqualityComparer(Of T)`-Interface, and corresponding StringComparer-Implementations, to allow different types of equality checks.

It would be perfect, if we could use

```
Select Case tagName With StringComparer.OrdinalIgnoreCase
Case "a"
Case "p"
Case Else
End Select
```

A slightly more functional style would use a `Comparer(Of T)`-style method

```
Select Case tagName With Function(x,y) StringComparer.OrdinalIgnoreCase.Compare(x,y)
Case "a"
Case "p"
Case Else
End Select
```

alternatively expressed as

```
Select Case tagName With AddressOf StringComparer.OrdinalIgnoreCase.Compare
Case "a"
Case "p"
Case Else
End Select
```

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.