A variable is a name given to a memory space that the program will use and manipulate. The variable should have a data type, depending on what we want to store in it, and the size of data that can hold.
Define a Variables
In C#, we define a variable as the following:
Example of defining a variable:
Datatype can be of the data types that we have discussed earlier, as well as used defined data type, such as a strut, class, etc.
Variable of the same data type can be defined all together. Example:
string str1, str2,str3;
Initialize a variable
Defining a variable is just reserving a space for the variable. Initializing is assigning a value to the variable.
Example of initializing a variable
string str; str = "TutorialsPanel";
Variable can be defined and assigned at the same time.
Example of defining and assigning a variable
string str = "TutorialsPanel";
More example of initializing variable
int a = 2; byte b = 14; double d = 15.99; char c = 'f'; float f = 5.2;