svaria
asked on
Convert vb.net (2003) to c# (2005)
Hello Experts,
Can anyone help me conver the following vb.net 2003 code to c# 2005 ?
Thanks
Public shared Function MD5HashHex(ByVal InString As String) as String
For SrcIdx = 0 To InString.Length() - 1
Data(DstIdx) = AscW(InString.Substring(Sr cIdx, 1)) And &H00FF
DstIdx += 1
Data(DstIdx) = (AscW(InString.Substring(S rcIdx, 1)) And &HFF00) >> 8
DstIdx += 1
Next
Dim Result As Byte() = md5.ComputeHash(Data)
Dim SResult as String = ""
For DstIdx=0 to Result.Length() - 1
SResult = Microsoft.VisualBasic.Form at(Result( DstIdx), "X").PadLeft(2, "0") & SResult
Next
Return SResult
End Function
Can anyone help me conver the following vb.net 2003 code to c# 2005 ?
Thanks
Public shared Function MD5HashHex(ByVal InString As String) as String
For SrcIdx = 0 To InString.Length() - 1
Data(DstIdx) = AscW(InString.Substring(Sr
DstIdx += 1
Data(DstIdx) = (AscW(InString.Substring(S
DstIdx += 1
Next
Dim Result As Byte() = md5.ComputeHash(Data)
Dim SResult as String = ""
For DstIdx=0 to Result.Length() - 1
SResult = Microsoft.VisualBasic.Form
Next
Return SResult
End Function
ASKER
Did you complie the code ?
I got 14 errors on that.
I got 14 errors on that.
there is nothing wrong with the conversion itself..it's not a fully "encapsulated" function and is using variables I assumed are declared publicly somewhere else on the page or class file...
in both versions, there are a bunch of external variables and references to the variables that are causing the errors...
SrcIdx,DstIdx,Data and md5
in both versions, there are a bunch of external variables and references to the variables that are causing the errors...
SrcIdx,DstIdx,Data and md5
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
{
for (int SrcIdx = 0; SrcIdx <= InString.Length() - 1; SrcIdx++) {
Data(DstIdx) = AscW(InString.Substring(Sr
DstIdx += 1;
Data(DstIdx) = (AscW(InString.Substring(S
DstIdx += 1;
}
byte[] Result = md5.ComputeHash(Data);
string SResult = "";
for (int DstIdx = 0; DstIdx <= Result.Length() - 1; DstIdx++) {
SResult = Microsoft.VisualBasic.Form
}
return SResult;
}
For future reference, there is a little online tool for converting c# to vb.net and viceversa:
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx