Web.com Web Hosting
Sign up for PayPal and start accepting credit card payments instantly.


Hello If you are new here, so you might want to subscribe for my feed so Subscribe in a reader. Or bring updates In Your Email

Thursday, October 28, 2010

How TO Create Objects in C#, Tutorial

Creating Objects
Declaring Variables Or Objects
A variable is a location in the memory that has a name and contains a value. The value could be an integer, such as 17, a decimal, such as 7.35, or a character, such as 'B'.  A variable is associated with a data type that defines the type of data, which can be stored in a object. For example, a object called BatsmanName will ideally  store characters, whereas a variable called High_Score will store numbers. A program refers to a object by its name.

Naming Variables/Objects in C#

The following rules are used for naming variables in C#:
  • Must begin with a letter or an 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.
  • Should not contain any embedded spaces or symbols such as ? ! @ # % ^ & * ( ) { } [ ] . , ; : " '  / and \. However, an underscore can be used wherever a space is required. Like high_score.
  • Can have any number of characters.
  • Keywords cannot be used as objects names. For example, you cannot declare a variable named class because it is a keyword in C#.
  • Must be unique. For example, to store four different numbers, four unique variable names need to used. Uppercase letters are considered distinct from lowercase letters.
The following are examples of valid variable variable names:

The following are examples of invalid variable names:

Important Note :- C# is a case-sensitive language. This means that the variable Batsman_Name is not the same as the batsman_name.

No comments:

Post a Comment

Related Posts with Thumbnails