Multiplication has greater priority - CSharp Language Basics

CSharp examples for Language Basics:Operator

Description

Multiplication has greater priority

Demo Code

using System;/*from   ww  w .j av a2  s . c  o  m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Multiplication has greater priority
      Console.WriteLine(1 + 2*3);
      // Forcing priority using parentheses
      Console.WriteLine((1 + 2)*3);
   }
}

Result


Related Tutorials