Use Logical and operator with an if statement in CSharp

Description

The following code shows how to use Logical and operator with an if statement.

Example


public class MainClass
{// w  ww .  j a v  a 2 s.com

  public static void Main()
  {

    int reactorTemp = 1500;
    string emergencyValve = "closed";

    if ((reactorTemp > 1000) && (emergencyValve == "closed"))
    {
      System.Console.WriteLine("Reactor meltdown in progress!");
    }

  }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception