C# *= 运算顺序

时间:2023-03-10 02:25:36
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 = ;
int b = ;
int c = ;
b *= a - + ;
c *= (a - + );
Console.WriteLine("b = " + b.ToString());
Console.WriteLine("c = " + c.ToString());
}
}
}

C# *= 运算顺序