日期:2014-05-18  浏览次数:20835 次

求高手将这段VB代码翻译成C#
public string jiemi(string PlainStr, string key)
{
  string str3;
  int start = 1;
  if ((Strings.Len(PlainStr) % 2) == 0)
  {
  string str4 = Strings.StrReverse(Strings.Left(PlainStr, (int) Math.Round

((double) (((double) Strings.Len(PlainStr)) / 2.0))));
  string str5 = Strings.StrReverse(Strings.Right(PlainStr, (int) Math.Round

((double) (((double) Strings.Len(PlainStr)) / 2.0))));
  PlainStr = str4 + str5;
  }
  int num3 = Strings.Len(PlainStr);
  for (int i = 1; i <= num3; i++)
  {
  string str6 = Strings.Mid(PlainStr, i, 1);
  string str2 = Strings.Mid(key, start, 1);
  if (((((Strings.Asc(str6) ^ Strings.Asc(str2)) < 0x20) | ((Strings.Asc(str6) 

^ Strings.Asc(str2)) > 0x7e)) | (Strings.Asc(str6) < 0)) | (Strings.Asc(str6) > 

0xff))
  {
  str3 = str3 + str6;
  }
  else
  {
  str3 = str3 + StringType.FromChar(Strings.Chr(Strings.Asc(str6) ^ 

Strings.Asc(str2)));
  }
  if (start == Strings.Len(key))
  {
  start = 0;
  }
  start++;
  }
  return str3;
}

 

 


------解决方案--------------------
这个就是C#代码呀,Microsoft.VisualBasic名称空间下的,楼主自己照着msdn转吧,很容易的
------解决方案--------------------
VB是这样的
 Function jiemi(ByVal PlainStr As String,ByVal keyAs String) As String
Dim str3 As String --声明变量
Dim start As Int32
If pDayCount >= 3 Then --if 判定
lResult = True
End If

For Each lEmployeeStartDateDataRow In lDataSet.Tables("EmployeeStartDateTable").Rows
.....
Next ---for 循环