WELCOME TO BHATI TRICKS WRITE FOR US ADVERTISE YOUR BLOG/SITE HERE POST YOUR ARTICLE/TRICK HERE


Sunday, 21 July 2013

VARIABLE DECLARATION IN C#


VARIABLE-DECLARATION-IN-C#

VARIABLE DECLARING IN C#:-
A variable is a location in the memory that has a name and contains a value. The value could be a integer, such as 27, a decimal, such as 6.35, or a character, such as L. a variable is associated with data type that defines the type of data, which can be stored in a variable. For example, a variable called TennisplayerName will ideally store characters, whereas a variable called high_score will store numbers. A program refers to a variable by its name.
NAMING OF VARIABLES IN C#:
The following rules are used in the naming of variable in c#:-
1.                  Must begin with a letter or a underscore('_'), which may be followed by a sequence of letters, digits (0-9) or underscores. The first character in a variable name cannot be a digit.
2.                  Should not contain any embedded spaces or symbols such as ? ! @ # + % $ () [] {} .,;:'”. however, an underscore can be used whenever a space is required, like high_score.
3.                  Must be unique, For example, to store four different numbers, four unique variable names need to be used. Uppercase letters are considered distinct from lower-case letters.
4.                  Can have any number of character.
5.                  Keywords cannot be used as variable names. For example, you cannot declare a variable named class because it is keyword in c#.
FOR EXAMPLE:-
Game_level
High_score
This_variable_name_is_very_long
The following are the invalid variable names:-
#score
2stank.
NOTE:-
c# is a CASE-SENSITIVE language. This means that the variable TennisPlayerName is not the same as the variable tennisplayername.
DECLARING AND INITIALIZING VARIABLES:-
you can declare and initialize variables by using the following syntax:
<data-_type><variable_name>=<value>;
In the preceding syntax, the <data_type> represents the kind of data types that will be stored in a variable and <value> specifies the value that needs to be stored in a variable.
Consider the following statement of variable declaration:
int age;
The preceding statement declares that variable age of the int data type and initializes the variable with the value 0. the int data type is used to store numeric data.
Consider the following statement:
char choice=”Y”
The data type represents the kind of data will be store in a variable.
Previous post is:- WHAT IS C#
next post is:- DATA TYPES IN C#
PLEASE IF YOU HAVE ANY DOUBT, PLEASE COMMENT IT BELOW THE POST.

Kindly Bookmark this Post using your favorite Bookmarking service:
Technorati Digg This Stumble Stumble Facebook Twitter

0 comments:

Post a Comment

 

ABOUT THE AUTHOR

Founder & Author:I ABHISHEK BHATI student of COMPUTER SCIENCE by education a Blogger by profession and compueters and electronics is my passion BHATI TRICKS is not start of blogging ABHISHEK BHATI launched his frist Marketing Site in 2013.
...Read More

GET FREE EMAIL UPDATES

Join us for free and get valuable content delivered right in your inbox.



recent comments

BHATI TRICKS Widget

| BHATI TRICKS © BHATI TRICKS. All Rights Reserved | | Back To Top |