Statements

Statements in C# are single entities that cause a change in the program's current state. They're commonly associated with some type of assignment statement, changing the value of a variable. A statement ends with a semicolon (;). Leave one out and the compiler will issue a prompt notification. Statements may span multiple lines, which could help make your code more readable, as the following example shows:

decimal closingCosts = loanOrigination
           + appraisal
           + titleSearch
           + insuranceAdvance
           + taxAdvance
           + points
           + realtorCommission
           + whateverElseTheyCanRipYouOffFor;

Had the statement been placed on one line, it would have either continued off the right side of the page or wrapped around in an inconvenient location. This way, each item ...

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.