C#

Variables in C Sharp

data type,int, double, string, char, float, decimal,Variables in C Sharp
Share it:

Variables in C Sharp


A variable is basically stored 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 used. 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 more for storing different kinds of data depending on the situation. 

Do you know:-

If you like the tutorial, then please share this tutorial with your friends on social media.

Share it:

C#

Post A Comment:

0 comments: