Operator precedence, with () and without () : Operator Precedence « Operator « C# / CSharp Tutorial






class MainClass
{
  public static void Main()
  {

    int myInt = 2 + 5 * 10;
    System.Console.WriteLine("2 + 5 * 10 = " + myInt);

    myInt = (2 + 5) * 10;
    System.Console.WriteLine("(2 + 5) * 10 = " + myInt);

    myInt = 2 * 20 / 5;
    System.Console.WriteLine("2 * 20 / 5 = " + myInt);

  }

}
2 + 5 * 10 = 52
(2 + 5) * 10 = 70
2 * 20 / 5 = 8








3.18.Operator Precedence
3.18.1.The Precedence of the C# Operators
3.18.2.Operator precedence, with () and without ()
3.18.3.multiple arithmetic operators
3.18.4.Order of Precedence for Expressions