The C# Logical Operator additionally evaluates the values and returns true or false as output. based on true-false the program behaves dynamically at run time. This operator is wide used with C# programming.

It is pronounced as and operator. It returns true if both or all the conditions square measure true and return false if any of the condition is false

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Logical_Operator_Example
{
 class Program
 {
 static void Main(string[] args)
 {
 string name, password;
 
 name = "pawan";
 password = "pawan@123";
 
 // evaluating both expresson and returns true if all are true.
 if (name == "pawan" && password == "pawan@123")
 {
 Console.WriteLine("Login Successful");
 }
 else
 {
 Console.WriteLine("Unauthorised Access");
 }
 Console.ReadLine();
 }
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *