Chapter 3. Writing C# Expressions

In This Chapter

  • Unary Operators

  • Binary Operators

  • The Ternary Operator

  • Other Operators

  • Enumeration Expressions

  • Array Expressions

  • Statements

  • Blocks

  • Labels

  • Declarations

  • Operator Precedence and Associativity

C# provides a complete set of language elements for writing expressions. An expression is a set of language elements combined to perform a meaningful computation. This chapter provides guidance in building C# expressions.

This chapter demonstrates expressions created with each of C#'s built-in operators. All aspects of operators are covered in order to provide an understanding of their effects.

There are four types of operators—unary, binary, ternary, and a few others that don't fit into a category. Unary operators affect ...

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