C# Introduction

  • C# is pronounced as C sharp.
  • C# is strong typed object-oriented programming language.
  • C# is keeping developed by a team in Microsoft.
  • C# programs run in .Net Framework.
  • C# syntax is easy to learn if the leaner is familiar with any of c, C++ or Java.
  • C# newest version is C# 5.0 and was released on August 15, 2012.
  • .Net Framework is a software framework developed by Microsoft.
  • .Net Framework consists of Framework Class Library (FCL) and Common Language Runtime (CLR).
  • FCL is a large predefined library which can be invoked directly by any of .Net Framework supported language, like C#.
  • CLR is an execution environment of .Net Framework and it provides memory management, security and exception handling services.
  • C# code can be compiled into Microsoft Intermediate Language (MSIL) and runs in .Net Framework.
  • CLR is responsible for converting MSIL into local machine language then run it.
  • .Net Framework provides language interoperability.

OS C# and .net framework relationship

You can see the .Net Framework is installed on an operation system, currently it is windows system. The C# application is running under the .Net Framework.

  • Object oriented programming (OOP) is a software developing paradigm which is using data fields and methods in a bunch of objects comparing with procedural programming.
  • Object refers to a particular instance of a class and a class is a combination of fields, methods and data structures.
  • The real world consists of all kinds of objects and the objects with the same actions and similar properties can belong to the same class.
  • For example, person can be a class and you or your friends are all objects. Tree is a class and the tree in front of your home is an object.
  • A class defines its attributes and methods. For example, a person has gender, age and color of eyes and he can run, swim and think.
  • OOP can create a new class, instantiate objects or reuse lots of existing classes like the classes in FCL in .Net Framework.


1
2
3
4
5
6
7
8
9
10
public class Person
{
	private string name;
	private int age;
	private DateTime dateOfBirth;

	public void drive(){
		// Drive code here
	}
}
See the above C# example, the first line defines the class name "Person". Inside the class, name, age and dateOfBirth are defined as attributes or instance virables. drive() is the method without any code. Generally speaking, all the business rules and logic can be defined in the methods.