Click here to Skip to main content
15,894,740 members
Articles / Programming Languages / C#

Parsing Strings to Boolean

Rate me:
Please Sign up or sign in to vote.
4.00/5 (2 votes)
15 Sep 2010CPOL 21.2K   1  
Handy extension method that parses common boolean expressions

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
16 Sep 2010Simon Dufour
If you don't need to check for other strings than True or False, then, you should use Boolean.Parse or Boolean.TryParse.// Return trueBoolean.Parse("true");// Return falseBoolean.Parse("false");// Exception.. you can prevent that from happening by using a try..catch// or using...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Ireland Ireland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions