I am working on hashing. I am hashing a phrase and I can only use 20 characters of the phrase.
How can I read only 20 characters of a string?
How can I compare strings if they are the same?
this compares the first 20 characters of string a
and b
if (String.Compare(a, 0, b, 0, 20) == 0)
{
// strings are equal
}
for culture specific comparison rules you can use this overload, that accepts a StringComparison enum:
if (String.Compare(a, 0, b, 0, 20, StringComparison.CurrentCultureIgnoreCase) == 0)
{
// case insensitive equal
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With