Introduction of C#
Introduction of C#
What is C#
• C# is new computer programming language
developed by Microsoft corporation, USA.
• C# is a fully object-oriented language like java.
• It has been designed to support the key features
of .NET Framework.
• It is a simple, efficient, productive and type safe
language derived from the popular C and C++
language suitable for developing Web based
applications.
Cont……..
Cont……
Object
Concept Concept
Oriented
C++
Power
Component
JAVA Oriented C# VB
Elegance Productivity
Evolution of C#
• Like java, C# is a descendant of C++ which in
turn is a descendant of C as shown in fig.
• C# borrows Java’s feature such as grouping of
classes, interfaces and implementation together
in one file so that programmers can edit the
code more easily.
• C# uses VB’s approach to form design, namely,
dragging control from a tool box, dropping them
onto forms and writing event handlers for them.
Characteristics of C#
• Simple
• Consistent
• Modern
• Object- Oriented
• Type- safe
• Versionable
• Compatible
• Inter-operability
• Flexible
How Does C# Differ from C++?
• C# Does not separate class definition from
implementation. Classes are defined and
implemented at the same place and therefore
there is no need for header files.
• The first character of the Main() method is
Capitalized. The Main must return void type value.
• C# doesn’t support #include statement.
• All the data types in C# are inherited from the
object super class and therefore they are objects.
• C# permits declaration of variables between goto
and label.
• C# doesn’t support Multilevel inheritance
How Does C# Differ From Java
• Arrays are declared differently in C#.
• Java uses static final to declare a class
constant while C# uses const.
• C# supports the struct type and java does not
• Java does not provide for operator overloading.
• C# provides the fourth type of iteration
statement, foreach for quick and easily iteration
over collections and array type data.
• C# adds internal, a new accessibility modifier.
Simple C# Program
• C# can be used to develop two categories of
programs, namely
– Executable application programs and
– Component libraries
• Executable programs are written to carry out
certain task and require the method Main in one
of the classes.
• Component libraries do not require Main method
because they are not stand alone application
programs. They are written for the use by other
applications. This concept is similar to applets
and application programs in Java.
C# Program
Executable Library
Programs Programs
Application
CLR Program
CLR
Output
Output
C# Program
• Class Sample
• {
• Public static void Main (String[] args)
• {
• System.Console.WriteLine(“C# is sharper
than C++);
• }
• }
• Compilation and Execution
Compilation
Language
Source Code Code (IL)
Compiler
JIT
Native Code
Compiler
Execution