1.9. C# Expressions

A simple expression in C# is the following (plus a few more expression types having to do with objects that you'll learn about in Chapter 13):

  • A constant: 7, false

  • A char(acter) literal: 'A', '&'

  • A string literal: "foo"

  • The name of any variable declared to be of one of the predefined types that we've discussed so far: myString, x

  • Any two of the preceding items that are combined with one of the C# binary operators (discussed in detail later in this chapter): x + 2

  • Any one of the preceding items that is modified by one of the C# unary operators (discussed in detail later in this chapter): i++

  • Any of the preceding simple expressions enclosed in parentheses: (x + 2)

1.9.1. Assignment Statements

Assigning a value to a variable is accomplished ...

Get Beginning C# 2008 Objects: From Concept to Code 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.