Home > Articles > Programming > C#

  • Print
  • + Share This
From the author of

From the author of

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 is visible, lined up nicely, and easier to understand.

  • + Share This
  • 🔖 Save To Your Account