c#: can you use a boolean predicate as the parameter to an if statement?
- by Craig Johnston
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.