Hello Team,
How to avoid case difference while doing String Comparison,
Eg. STR1: Happy
STR2: HAPPY
While comparing these strings ,the result is not zero.
i just need the result as zero.
Hello Team,
How to avoid case difference while doing String Comparison,
Eg. STR1: Happy
STR2: HAPPY
While comparing these strings ,the result is not zero.
i just need the result as zero.
@Akhil_Raveendran
Convert both string either upper or lower for comparison
STR1.ToUpper=STR2.ToUpper
You can try below expression also to compare two strings.
String.Compare(STR1,STR2,True)
Here, True indicates ignore case.
You can compare using Microsoft String Comparison class.
STR1.Equals(STR2, StringComparison.InvariantCultureIgnoreCase)
Refer below table for stringcomparison class arguments:
CurrentCulture | 0 | Compare strings using culture-sensitive sort rules and the current culture. |
---|---|---|
CurrentCultureIgnoreCase | 1 | Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared. |
InvariantCulture | 2 | Compare strings using culture-sensitive sort rules and the invariant culture. |
InvariantCultureIgnoreCase | 3 | Compare strings using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings being compared. |
Ordinal | 4 | Compare strings using ordinal (binary) sort rules. |
OrdinalIgnoreCase | 5 | Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared. |