Home > Articles


  • Print
  • + Share This


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 any valid identifier as defined in Chapter 2, "Getting Started with C#."

A declaration with initialization looks like this:

<type> <identifier> = <expression>;

The type and identifier are the same as the previous example. The equal 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

Related Resources

There are currently no related titles. Please check back later.