class
{
static void Main()
{
System.Console.WriteLine ("{0}", 5 > 2);
System.Console.WriteLine ("{0}", 6 < 2);
System.Console.WriteLine ("{0}", 1 < 1);
System.Console.WriteLine ("{0}", 1 <= 1);
System.Console.WriteLine ("{0}", 3 != 3);
System.Console.WriteLine ("{0}", 1 !=2);
}
}
OutputTrue
False
False
True
False
True
Here the first line says WriteLine("{0}", 5 > 2); Is 5 > 2 ? Yes. So the condition 5 > 2 evaluates to true. Hence the {0} in WriteLine is replaced with True and the WriteLine function displays True. 5 > 2 is called a condition. A condition is like a question which has to result in a yes or no or a true or false. In this case the number 5 is greater than the number 2 and hence the function evaluates to true. C# understands the words true and false.
C# Basic Topics
Console Application
C# Random Topics
Monday, September 13, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment