麻烦帮小弟我转换成C#语法
麻烦帮我转换成C#语法!
转换成C#
------解决方案--------------------
public int VKB_param(int VirtualKey,int flag)
{
string s,Firstbyte,Secondbyte;
s=Firstbyte=Secondbyte=string.Empty;
int S_code;
if(flag==1)
{
Firstbyte="00";
}else
{
Firstbyte="C0";
}
S_code=MapVirtualKey(VirtualKey, 0);
Secondbyte="00"+S_code;
Secondbyte=Secondbyte.Substring(Secondbyte.Length-1,2);
s="$"+Firstbyte+Secondbyte+"0001";
return Convert.ToInt32(s);
}
不一定正确,Convert.ToInt32(s);这个没搞定白delphi为什么可以转换,c#好像不行。
- Delphi(Pascal) code
function VKB_param(VirtualKey:Integer;flag:Integer):Integer; //函数名 var s,Firstbyte,Secondbyte:String; S_code:Integer; Begin if flag=1 then //按下键 begin Firstbyte :='00' end else //弹起键 begin Firstbyte :='C0' end; S_code:= MapVirtualKey(VirtualKey, 0); Secondbyte:='00'+inttostr(s_code); Secondbyte:=copy(Secondbyte,Length(Secondbyte)-1,2); s:='$'+Firstbyte + Secondbyte + '0001'; Result:=strtoint(s); End;
转换成C#
------解决方案--------------------
public int VKB_param(int VirtualKey,int flag)
{
string s,Firstbyte,Secondbyte;
s=Firstbyte=Secondbyte=string.Empty;
int S_code;
if(flag==1)
{
Firstbyte="00";
}else
{
Firstbyte="C0";
}
S_code=MapVirtualKey(VirtualKey, 0);
Secondbyte="00"+S_code;
Secondbyte=Secondbyte.Substring(Secondbyte.Length-1,2);
s="$"+Firstbyte+Secondbyte+"0001";
return Convert.ToInt32(s);
}
不一定正确,Convert.ToInt32(s);这个没搞定白delphi为什么可以转换,c#好像不行。