C Sharp for Beginners/Operators

Operators perform actions on data. There are three types of operators in C#:


 * A unary operator has the form . An example is the negation operator:   gives you   with the opposite sign (if   was 12 you would get -12).
 * A binary operator has the form . An example is the assignment operator:   sets   to 1234.
 * A ternary operator has three objects on which it acts. C# only has one ternary operator, the conditional operator:  gives you "good" if   is equal to 1234, but "bad" if   is not equal to 1234.

You can combine operators in almost any way you like. Here is an example incorporating many different operators:

Prefix and Postfix
The  and   operators can be placed before (prefix) or after (postfix) variables. There is a subtle difference between the two; if placed before, it increments or decrements and then returns the new value, and if placed after, it increments or decrements and returns the old value. For example: