Variables in C# Assignment Help


  • A variable is used to store values of various data types and a name is provided to a storage area that is actually a variable.
  • Variable has a specific data type, which measures the size of the variable's memory.

Declaring and Initializing Variables

Variable Declaration Syntax

  • Variable can be declared by any data type followed by variable name

Variables in C# Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com

data_type variable_name;

Here, data_type can be char, int, float, double, or any user-defined data type, and

variable_name can be any identifer.


int age, no;

char c, ch;

float salary;

  • Assigning values to a variable is called initialization
  • Initialization can be done with an equal sign followed by a value or an expression.
  • Variables can also be initialized in the declaration section itself.


variable_name = value;

data_type variable_name = value;


int no = 3, age = 5;

double pi = 3.14159;

char c = 'x';

The following is an example for variable declaring and initializing

variables image 1