Relational Operators C# with Example



Relational Operators C# with Example

 using System;

namespace CSharpFundamentals
{
    class RelationalOperators
    {
        private static void Main(string[] args)
        {
			Console.WriteLine("Less Then ( < ) Relational Operator");
			Console.WriteLine("10 < 10 : {0}", 10 < 10);
			Console.WriteLine("10 < 20 : {0}", 10 < 20);
			Console.WriteLine("20 < 10 : {0}\n", 20 < 10);
			
			Console.WriteLine("Greater Then ( > ) Relational Operator");
			Console.WriteLine("10 > 10 : {0}", 10 > 10);
			Console.WriteLine("10 > 20 : {0}", 10 > 20);
			Console.WriteLine("20 > 10 : {0}\n", 20 > 10);
			
			Console.WriteLine("Less Then or Equal To ( <= ) Relational Operator");
			Console.WriteLine("10 <= 10 : {0}", 10 <= 10);
			Console.WriteLine("10 <= 20 : {0}", 10 <= 20);
			Console.WriteLine("20 <= 10 : {0}\n", 20 <= 10);
			
			Console.WriteLine("Greater Then or Equal To( >= ) Relational Operator");
			Console.WriteLine("10 >= 10 : {0}", 10 >= 10);
			Console.WriteLine("10 >= 20 : {0}", 10 >= 20);
			Console.WriteLine("20 >= 10 : {0}\n", 20 >= 10);
			
			Console.WriteLine("Equal To( == ) Relational Operator");
			Console.WriteLine("10 == 10 : {0}", 10 == 10);
			Console.WriteLine("10 == 20 : {0}", 10 == 20);
			Console.WriteLine("20 == 10 : {0}\n", 20 == 10);

			Console.WriteLine("Not Equal To( != ) Relational Operator");
			Console.WriteLine("10 != 10 : {0}", 10 != 10);
			Console.WriteLine("10 != 20 : {0}", 10 != 20);
			Console.WriteLine("20 != 10 : {0}\n", 20 != 10);			
		}
    }
}
 

0 Comment's

Comment Form