C#运算符优先级

using System;namespace OperatorsAppl {class Program {static void Main(string[] args) {int a = 20;int b = 10;

编程学习网为您整理以下代码实例,主要实现:C#运算符优先级,希望可以帮到各位朋友。

using System;
namespace OperatorsAppl {
   class Program {
      static voID Main(string[] args) {
         int a = 20;
         int b = 10;
         int c = 15;
         int d = 5;
         int e;
         e = (a + b) * c / d;     // ( 30 * 15 ) / 5
         Console.Writeline("Value of (a + b) * c / d is : {0}", e);

         e = ((a + b) * c) / d;   // (30 * 15 ) / 5
         Console.Writeline("Value of ((a + b) * c) / d is  : {0}", e);

         e = (a + b) * (c / d);   // (30) * (15/5) {0}", e);

         e = a + (b * c) / d;    //  20 + (150/5) {0}", e);
         Console.Readline();
      }
   }
}

本文标题为:C#运算符优先级

下一篇: C#赋值运算符