Using Expressions

An expression is a combination of operators and operands that can be used to compute a value. Expressions are used to provide specific information. An expression generally consists of one or more operators and at least one operand. C# supports the following expressions:

  • Value

  • Variable

  • Namespace

  • Type

  • Method group

  • Property access

  • Event access

  • Indexer access

Operators and Operands

An operator is a symbol that signifies an action. An operand refers to the objects that are being manipulated. For instance, in the expression 2-a, 2 and a are the operands and – is the operator.

Classification of Operators

Operators can be organized into four categories: primary, unary, binary, and ternary operators. Before each category is examined, it ...

Get Special Edition Using C# 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.