Home > Articles > Programming > C#

  • Print
  • + Share This
From the author of

From the author of

Declarations

Declarations enable definition and announcement of the existence and nature of program data. There are two forms of declaration in C#: simple declaration and declaration with initialization. A simple declaration takes the following form:

<type> <identifier>;

The type may be any C# or user-defined type. The identifier is a valid identifier.

A declaration with initialization looks like this:

<type> <identifier> = <expression>;

The type and identifier are the same as the previous example. The equals sign takes the evaluated expression on its right and loads it into the variable declared on the left. The expression can be any valid C# statement evaluating to the type of variable specified by type. The declaration is a statement followed by a semicolon.

  • + Share This
  • 🔖 Save To Your Account