C# *= 运算顺序

a *= a + b *c;

不管等号右边有没有括号,总是先算右边;

即等价于 a = a *(a + b*c);

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CsharpTEST
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 10;
            int c = 10;
            b *= a - 10 + 2;
            c *= (a - 10 + 2);
            Console.WriteLine("b = " + b.ToString());
            Console.WriteLine("c = " + c.ToString());
        }
    }
}

posted @ 2015-05-19 14:53  Mr.Ethan  阅读(408)  评论(0编辑  收藏  举报