C#

C# | Variable | A tour of the C# language

Variable In C#,variable,identifier
Share it:
C# | Variable


Variable In C#


variable is basically storage in the computer’s memory where you can put a value that will be used by your program. The variable has a name, which identifies it among other variables and allows you to access the value of the variable. It has an address which determines where in the memory it resides. It has a value that is either assigned by the user or a result of a calculation although a variable can have a value of null or nothing. 


A variable has a type, which signifies what kind of data the variable contains. A variable has a lifetime which determines how long in the program the variable is usable. And finally, a variable has a scope that tells you where in a program the variable is available for use.


The name of a variable is called an identifier. The variable's content is accessed or inserted using its identifier. When naming variables in C#, there are some rules you must follow.



  • A variable should start with an alphabet (a-z or A-Z)
  • It cannot contain odd characters such as #,? ^, $.
  • You cannot use any of the reserved words in C# as names for your variables.
  • A variable name cannot contain spaces.
  • Variables are case-sensitive.
  • You cannot have two variables with the same name inside the same scope.


A variable has a data type which is the format or kind of data stored in it. The most common data types are int, double, string, char, float, decimal and a lot of lot more for storing different kinds of data depending on the situation. More complex data types can be made in C# by making your own classes or structures.
Share it:

C#

Post A Comment:

0 comments: