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 theIEqualityComparer(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
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.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
A slightly more functional style would use a
Comparer(Of T)
-style methodalternatively expressed as