这一段vb代码转成c#代码, 帮帮吧。

Private Function AscToChar(ByVal sAsc As String) As String

Dim iLen As Integer
Dim i As Integer

On Error GoTo err_Trans

AscToChar
= ""
iLen
= CInt(Len(sAsc) / 2)
For i = 0 To iLen - 1
If CInt("&H" & Mid(sAsc, i * 2 + 1, 2)) < &H20 Then
AscToChar
= ""
Exit Function
Else
AscToChar
= AscToChar & Chr(CInt("&H" & Mid(sAsc, i * 2 + 1, 2)))
End If
Next i
exit_Trans:
Exit Function
err_Trans:
AscToChar
= ""
Resume exit_Trans
End Function
慕妹3146593
浏览 274回答 2
2回答

慕莱坞森

private string AscToChar(string sAsc){ string functionReturnValue = null; int iLen = 0; int i = 0; // ERROR: Not supported in C#: OnErrorStatement functionReturnValue = ""; iLen = Convert.ToInt32(Strings.Len(sAsc) / 2); for (i = 0; i <= iLen - 1; i++) { if (Convert.ToInt32("&H" + Strings.Mid(sAsc, i * 2 + 1, 2)) < 0x20) { functionReturnValue = ""; return functionReturnValue; } else { functionReturnValue = functionReturnValue + Strings.Chr(Convert.ToInt32("&H" + Strings.Mid(sAsc, i * 2 + 1, 2))); } } exit_Trans: return functionReturnValue; err_Trans: functionReturnValue = ""; // ERROR: Not supported in C#: ResumeStatement return functionReturnValue;}
打开App,查看更多内容
随时随地看视频慕课网APP