I'm trying to convert a program from VB to C# in an effort to give myself a crash course on learning C#. For the most part, things have been going fine but I've run into one problem for which I can't seem to find a solution.
The original VB code looks like this:
CODE
Protected Friend Function getMd5Hash(ByVal input As String) As String
Dim md5Hasher As New MD5CryptoServiceProvider()
Dim data As Byte() = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input))
Dim sBuilder As New StringBuilder()
For i As Integer = 0 To data.Length - 1
sBuilder.Append(data(i).ToString("x2"))
Next i
Return sBuilder.ToString()
End Function
and I converted it to:
CODE
protected internal string getMd5Hash(string input)
{
MD5CryptoServiceProvider md5Hasher;
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i <= data.Length - 1; i++)
{
sBuilder.Append(data(i).ToString("x2"));
}
return sBuilder.ToString();
}
It is throwing the error 'data' is a 'variable' but is used like a 'method' underlining the data in the
CODE
sBuilder.Append(data(i).ToString("x2"));
any help or point in the right direction would be greatly appreciated
thanks