How to Toggle String Case in .NET
For VB.NET users:Public Function ToggleCase(input As String) As String Dim result As String = String.Empty Dim inputArray As Char() = input.ToCharArray() For Each c As Char In inputArray If Char.IsLower(c) Then result += [Char].ToUpper(c) Else result +=...
For VB.NET users:
Public Function ToggleCase(input As String) As String
Dim result As String = String.Empty
Dim inputArray As Char() = input.ToCharArray()
For Each c As Char In inputArray
If Char.IsLower(c) Then
result += [Char].ToUpper(c)
Else
result += [Char].ToLower(c)
End If
Next
Return result
End Function
One more:
Dim mystring As New StringBuilder("AbCd")
For i As Integer = 0 To mystring.Length - 1
Dim c As Char = mystring(i)
mystring(i) = If([Char].IsLower(c), [Char].ToUpper(c), [Char].ToLower(c))
Next