codeGK
Code it ALL
C# Variables - CodeGK
♦ C# Variables

♣ About C# Variables

Variables are Dummy data types which hold the value of Actual Data Types.
Variables are not compulsory for writing programs, but they come extremely handy for organization and generalization of code.
Also the variable can be classified further on the basis of accessing property:-
  • Global Variable
  • Local Variable

♣ Example1: Global Variable in C#

The variable which can be accessed from any part of the code is called Global Variable.
Note that the variable should be declared and initialized above of calling.
These variable are so-called having Global Scope, that is, the scope of the variable is not limited to any part of the code.
In this example, Global Variable is illustrated.
Example
Input:
Output:

♣ Example2: Local Variable in C#

The variable which can be accessed from a particular part of the code is called Local Variable.
These variable are so-called having Local Scope, that is, the scope of the variable is limited to a particular part of the code.
In this example, Local Variable is illustrated.
Example
Input:
Output:
Prev_LessonNext_Lesson