Csharp/CSharp Tutorial/Language Basics/Variable Definition — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 15:19, 26 мая 2010

Define and assign value to variables

The general form of initialization is shown here:


<source lang="csharp">type var = value;</source>

Dynamic initialization.

Declare two or more variables using the same declaration statement. Just separate their names by commas:


<source lang="csharp">int x, y; // both declared using one statement</source>

Variable definition

A variable is a named memory location that can be assigned a value.

To declare a variable, you will use a statement like this:


<source lang="csharp">type var-name;</source>

  1. type specifies the type of variable being declared
  2. var-name is the name of the variable.