c#: can you use a boolean predicate as the parameter to an if statement?
Posted
by Craig Johnston
on Stack Overflow
See other posts from Stack Overflow
or by Craig Johnston
Published on 2010-05-06T11:09:17Z
Indexed on
2010/05/06
11:18 UTC
Read the original article
Hit count: 190
In C#, can you use a boolean predicate on its own as the parameter for an if statement?
eg:
string str = "HELLO";
if (str.Equals("HELLO"))
{
Console.WriteLine("HELLO");
}
Will this code output "HELLO", or does it need to be:
string str = "HELLO";
if (str.Equals("HELLO") == true)
{
Console.WriteLine("HELLO");
}
If there is anything else wrong with the above code segments, please point it out.
© Stack Overflow or respective owner