我試圖將一段代碼從C#轉換爲VB.NET。原來的代碼示例可以在這裏位於(見接受的答案):運算符<未爲'char'和'integer'類型定義
我做了使用an online tool粗轉換,雖然我在那裏ch
char對象正在對檢查點異常十六進制字符的範圍。
If (ch < &HFD AndAlso ch > &H1F)
提出的例外是operator < is not defined for types 'char' and 'integer'
。我在哪裏錯誤的VB解釋?
Function RemoveTroublesomeCharacters(inString As String) As String
If inString Is Nothing Then
Return Nothing
End If
Dim newString As New StringBuilder()
Dim ch As Char
For i As Integer = 0 To inString.Length - 1
ch = inString(i)
' remove any characters outside the valid UTF-8 range as well as all control characters
' except tabs and new lines
If (ch < &HFD AndAlso ch > &H1F) OrElse ch = ControlChars.Tab OrElse ch = ControlChars.Lf OrElse ch = ControlChars.Cr Then
newString.Append(ch)
End If
Next
Return newString.ToString()
End Function