.NET 2.0 Tip: Please Understand The Meaning of .TryParse
.NET 2.0 has this nice method called
.TryParse. It will Try to Parse something for you, be it some Integer, String, Boolean or Date. Then it let's you know if it succeeded. This means e.g. that a Boolean.TryParsewill return True if it can convert your input to a boolean. So *don't* try something like this:
blnValue = Boolean.TryParse(stringContainingBooleanValue, blnValue)It will happily return True when the string contains either "True" or "False" :-)
:-)
0 Comments:
Post a Comment
<< Home