2
Answers

String parameter is not equal

Dy Oswald

Dy Oswald

17y
1.8k
1

I write a function that passes a string parameter to my ws and return the hash code of that parameter.
But when I compare it to the hash code of the original string in my client-side code, they were not equal.
Could anybody help me please?

WS Code:
[WebMethod]
public int MyWebFunction(string data)
{
   int retVal = data.GetHashCode();

   ... rest of my code ...

   return retVal;
}


Client-Side Code:
public bool DataUploader(string data)
{
   bool retVal;
   int hashCode;
   
   MyWebService ws = new MyWebService();
   hashCode = ws.MyWebFunction(data);

   if (hashCode == data.GetHashCode())
   {
      retVal = true;
   }
   else
   {
      retVal = false;
   }

   return retVal;
}

Why does it always returns false?

Answers (2)