1. .ToUpper()
returns the string in UPPERCASE
.
so that all letters in in your string variable theStatus
becomes capital.
basic advantage of using .ToUpper()
is while comparing the string if you want to ignore
the case
(either upper
or lower
) you can convert
the String to Capital using .ToUpper()
and then compare with CAPITAL
String.
if (theStatus.ToUpper() == "APPROVE")
2. you can achieve same thing by converting
your variable theStatus
into Lower case
and then compare with LowerCase Letters
using .ToLower()
function.
if (theStatus.ToLower() == "approve")
3. You can do same thing using Equals()
Method by passing StringComparison.InvariantCultureIgnoreCase
so that while comparing Strings Equals
method Ignore
the Case
and perform Comparision
.
Note : here you do not need to compare with either LOWER
or UPPER
case letters because Equals()
just ignore the case and do the Comparison
.
1=> if (theStatus.Equals("APPROVE", StringComparison.InvariantCultureIgnoreCase))
2=> if (theStatus.Equals("approve", StringComparison.InvariantCultureIgnoreCase))
3=> if (theStatus.Equals("aPpRoVe", StringComparison.InvariantCultureIgnoreCase))
all of the above cases are true
if your theStatus
contains approve
in any case.