Thursday, December 28, 2017

Declaring and Initializing Variables in C#


You can declare and initialize variables by using the following syntax:

< data_type > < variable_name > = < value >;

In the above syntax, the represents the kind of data type that will be stored in a variable and specifies the value that needs to be stored in the variable.

Consider the following statement that declares a variable:

int marks = 79;

The preceding statement declares a variable named ‘marks’ of the int data type. In addition, the statement initializes the variable with the value, 79. The int data type is used to store numeric data (integers).


Consider another following statement:

char isSuccess = ’y’;


The preceding statement declares the variable ‘isSuccess’ of the char data type and initializes the variable with the value, y.


Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: