Unary Operators
Explore how unary operators manipulate variable values in C# including pre-increment, post-decrement, sign negation, and logical negation. Understand their differences and practical usage in coding expressions.
We'll cover the following...
We'll cover the following...
In the previous lesson we discussed the basic operators used in C#. One of the types listed was the unary operators. Let’s learn about them now.
Unary Operators Example
Take a look at the example below which uses the unary operators.
Code Explanation
When evaluating expressions:
postIncrement(x++) andpostDecrement(x--) operators return their current value and then apply the operators.preIncrement(++x) andpreDecrement(--x) operators apply the operators to the variable prior to returning the final value.
In the code ...