Tuesday, 20 August 2013

Parse to Boolean or check String Value

Parse to Boolean or check String Value

If I have a variable that pulls a string of true or false from the DB,
which would be the preferred way of checking its value?
string value = "false";
if(Boolean.Parse(value)){
DoStuff();
}
I know there are different ways of parsing to bool - this is an example
or
string value = "false";
if(value == "true"){
DoStuff();
}
I am pulling a lot of true/false values from the DB in string format, and
want to know if these methods make any performance difference at all?

No comments:

Post a Comment