Hate stuff like this:
if (myValue == "true")
Like this:
int compareResult = string.Compare(myValue, true.ToString(), StringComparison.OrdinalIgnoreCase);
Two things.
- Explicit control over casing, nothing is assumed.
- No magic hard coded string i.e. true.ToString() versus “true”.
Note that true.ToString() is actually “True”.
0 comments:
Post a Comment