The Operators Precedence is useful in the c# programming language which defines multiple operators in a single expression, and the evaluation of expression can be happened based on the priority of operators.
In the given example, the multiplication operator (*) is having higher precedence than the addition operator (+). So if you use both addition (+) and multiplication (*) operators in a single expression, first, it will evaluate the multiplication part and then the addition part in expression.
Following is the given example of defining an expression with operator precedence in the c# programming language.
int a = 7 + 5 * 3;
When you execute the above statement, the multiplication part (5 * 3) will be evaluated first. After that, the additional part (7 + 5) will be executed, and the value will become 25.
As said earlier, the multiplication (*) operator is having higher precedence than the addition (+) operator so that the first multiplication part will be executed.
The given following table lists, the different types of operators available in c# relational operators.
|Postfix / Prefix||++, --|
|Unary||+, -, !, ~|
|Multiplicative||*, /, %|
|Relational||<, <=, >, >=|
|Bitwise||&, |, ^|
|Assignment||=, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=|
C# Operator Precedence Example
public class Program
public static void Main(string args)
int a = 10, b = 7, c = 8;
int result = a / b + c;
bool result2 = a <= b + c;
If we observe the given above example, you implemented operator precedence with multiple operators. The evaluation of expressions will be done based on operators' priority in the c#.