Combine confition with 'and'/'or' inside if statement in CSharp

Description

The following code shows how to combine confition with 'and'/'or' inside if statement.

Example


       //from  ww w  . j  av  a 2 s.c  om
using System;

public class MainClass{
  static void Main(string[] args){
    int a = 5, b = 5, c = 10;

    if (a == b)
      Console.WriteLine(a);

    if ((a > c) || (a == b))
      Console.WriteLine(b);

    if ((a >= c) && (b <= c))
      Console.WriteLine(c);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




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