Mega Code Archive

 
Categories / C# Tutorial / Operator
 

Operator precedence, with () and without ()

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