Chapter 8. Expressions and Operators

Expressions

This chapter defines expressions and describes the operators provided by C#. It also explains how you can define the C# operators to work with your user-defined classes.

An expression is a string of operators and operands. Some of the constructs that can act as operands are

  • Literals

  • Constants

  • Variables

  • Method calls

  • Element accessors, such as array accessors and indexers

  • Other expressions

The C# operators take one, two, or three operands. An operator

  • Takes its operands as input

  • Performs an action

  • Returns a value, based on the action

Expressions can be combined, using operators, to create other expressions, as shown in this expression, with three operators and four operands:

Evaluating an expression is the process ...

Get Illustrated C# 2008 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.