About C# programming

C# pronounced “see sharp”. C# is an object-oriented programming language and it is part of the Microsoft.NET
C# syntax is very similar to C++, and has similar power of Java, coupled with the simplicity of Visual Basic.


Variables: Variable allows the programmer to give a name, or identifier, to a piece of data or value; we can then use that identifier to store, modify, and retrieve the data.

string strName;
int intAge;


Commonly Used Data Types
int: Whole numbers in the range -2,147,483,648 to 2,147,483,647.
decimal: Up to 28 decimal places. You’ll use decimal most often when dealing with business figures.
string: Any text value.
char: A single character (letter, number, or symbol).
bool: True or false.


Operators:  an operator is a symbol that has meaning when applied to values.


concatenation operator

Arithmetic operator

Conditional or logical operator


Condition statement causes a program to branch and executing a block of code when a condition is true or false. Common conditional statements includes if, else if and else statement as well as case statement.


Loop causes a block of code to execute repeatedly for as long as the test expression or condition remains true. There are two basic kinds of loop in C#
While loop

int count = 0;
while (count <= 15) {
	// Below we use a sneaky way to convert our int to a string
	lblDisplay.Text = Convert.ToString(count);
	// C# uses the operator ++ to increase a variable by 1, you  could also write this as count=count+1;

For loop

int n;
for (n = 1; i <= 10; i++) {
	lblMessage.Text = Convert.ToString(n);


Object Oriented Programming (OOP): Object Oriented Programming approach, encourage structured way of programming, by analyzing and breaking down problem and organizing code into modules, each module defines classes that can be imported and used in other modules.


Class and Object: class can simply be recognized as the blueprint for creating an object. In programming term we say an object is an instance of a Class, that is, you create an instance of Class, which is an Object. For example:

A Car Vehicle, instances (objects) may include Car, Jeep and Trailer as you can see car virtually abstract until represented in physical form (object).
Also note that this objects (Car, Jeep, Trailer) have the features which all vehicles have in common (which is why that are regarded as family of vehicle), this may include, tires, steering, engines, driver seat. Although they may have some few indifference, for instance trailer may have more tires than car, but there similarity however overemphasized that they belongs to a group of family called vehicle class.

Properties: hold specific information relevant to that class of object. You can think of properties as characteristics of the objects that they represent. Our Vehicle class might have properties such as Color, Height, and Length.
Methods: are actions that objects of the class can be told to perform. So the vehicle class could have methods such as move(), and stop().



Scope of a Class
Public: Defining a property or method of a class as public allows that property or method to be called from outside the class itself. In other words, if an instance of this class is created inside another object, public methods and properties are freely available to the code that created it. This is the default scope in C# classes.

Private: If a property or method of a class is private, it cannot be used from outside the class itself. If an instance of this class is created inside an object of a different class, the creating object has no access to private methods or properties of the created object.

Other Important features of OOP include:
• Inheritance
• Polymorphism
• Encapsulation


Since C# is our chosen programming language for this ASP.NET tutorial we will be seeing more sample C# codes.


Next »