Operating on variables

Operators apply simple operations such as addition and multiplication to operands such as numbers. They usually return a new value that is the result of the operation.

Most operators are binary, meaning that they work on two operands, as shown in the following pseudocode:

    var resultOfOperation = FirstOperand operator SecondOperand; 

Some operators are unary, meaning they work on a single operand.

A ternary operator works on three operands.

Experimenting with unary operators

Two common unary operators are used to increment ++ and decrement -- a number.

In Visual Studio 2017, from the View menu, choose Other Windows, and then C# Interactive.

Note

In Visual Studio Code, create a new console application and write your own statements ...

Get C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.