这是一段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
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
解决方案 »
- C# 如何对文本进行加密解密???
- 寻求CAD图纸批量打印最佳解决方案
- 精通.net以及欲学习者请加入群69129291
- 笔记本 响应不了C#程序 热键
- 在picturebox中绘图时,如何将坐标系统转换为Y轴向上为正(默认向下为正)?
- 如何通过gridview控件添加一列,同时数据库中的表也添加一列。
- 在C#中如何合并两个RichtextBox中的内容?
- 请问高人,在.NET下进行RSA数据加密,如何设置keysize=128?
- 一个很弱的问题关于数组的
- 有关C#和C++的类型共用问题
- 如何在asp.net中调用mfc动态库,高手来解答~~~~~
- 另开了一个线程执行某个函数,怎样知道这个线程什么时候执行完成?
机械得很,不行
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;
}
{
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;
}
}