16,718
社区成员
发帖
与我相关
我的任务
分享 Sub Main()
'定义字符串
Dim oldstr() As Char = "HellO,WolD!".ToCharArray
Dim newstr As String = ""
For Each c As Char In oldstr
'判断是否是字符
If Char.IsLetter(c) = True Then
If Char.IsLower(c) = True Then
'专大写
newstr += Char.ToUpper(c)
Else
'专小写
newstr += Char.ToLower(c)
End If
Else
newstr += c
End If
Next
'输出新字符串
Console.WriteLine(newstr)
End SubSub Main()
Dim s As String = "HellO,WolD!"
Dim result As String = New String((From c In s Select IIf(Char.IsLower(c), _
Char.ToUpper(c), _
Char.ToLower(c))).Cast(Of Char).ToArray(), 0, s.Length)
Console.WriteLine(result)
Console.ReadKey()
End Sub