这是一段VB的代码,那个高手帮我转化成C#,谢谢!
Private Function DeCode(ByVal str As String) As String
Dim str1, cc As String
Dim ii, num As Integer
ii = 1
num = Len(str)
Do While ii <= num
  cc = Mid(str, ii, 2)
  If Abs(CLng("&H" & cc)) < 127 Then
    cc = Chr(CLng("&H" & cc))
  Else
    cc = Mid(str, ii, 4)
    cc = Chr(CLng("&H" & cc))
    ii = ii + 2
  End If
  str1 = str1 & cc
  ii = ii + 2
Loop
DeCode = str1
End Function

解决方案 »

  1.   

    http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspxhttp://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
      

  2.   

    http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
    机械得很,不行
      

  3.   

    楼主呀,我转换了一下,不知行不行。呵呵。
    private string DeCode(string str)
    {
    string str1,cc;
    int ii,num;
    ii = 1;
    num = str.Length;
    while (ii <= num)
    {
    cc = str.Substring(ii,2);
    if (System.Math.Abs(Convert.ToDecimal("&H" + cc)) < 127)
    cc = (Convert.ToInt32("&H" + cc)).ToString();
    else 
    {
    cc = str.Substring(ii,4);
    cc = (Convert.ToInt32("&H" + cc)).ToString();
    ii += 2;
    }
    str1 = str1 + cc;
    ii += 2;
    }
    return str1;
    }
      

  4.   

    public static string DeCode(string str)
    {
    string str1="",cc;
    int ii, num;
    ii=0;
    num=str.Length;
    while(ii<num)
    {
    cc=str.Substring(ii,2);
    if(Math.Abs(int.Parse(cc,System.Globalization.NumberStyles.HexNumber))<127)
    {
    byte[] bye=new byte[1];
    bye[0]=byte.Parse(cc,System.Globalization.NumberStyles.HexNumber);
    cc=System.Text.Encoding.Default.GetString(bye);
    }
    else
    {
    cc=str.Substring(ii,4);
    byte[] bye=new byte[2];
    bye[0]=byte.Parse(cc.Substring(0,2),System.Globalization.NumberStyles.HexNumber);
    bye[1]=byte.Parse(cc.Substring(2,2),System.Globalization.NumberStyles.HexNumber);
    cc=System.Text.Encoding.Default.GetString(bye);
    ii+=2;
    }
    str1+=cc;
    ii+=2;
    }
    return str1;
    }
    }