@ 2010 Tata McGraw-Hill Education
1
Education
Introducing C#Introducing C#
C #’ (pronounced as ‘C sharp’) is a new computer-programming language
developed by Microsoft Corporation, USA. C# is a fully object-oriented language
like Java and is the first component –oriented language. It has been designed t
support the key features of .NET Framework, the new development platform of
Microsoft for building component-based software solutions. It is a simple, efficient,
productive and type-safe language derived from the popular C and C++ languages.
Although it belongs to the family of C / C++, it is a purely objected-oriented,
modern language suitable for developing Web based applications
@ 2010 Tata McGraw-Hill Education
2
Education
 It is a brand new language derived from the C / C++ family
 It simplifies and modernizes C++
 It is the only component-oriented language available today
 It is the only language designed for the .NET Framework
 It is a concise, lean and modern language
 It combines the best features of many commonly used languages: the productivity of
Visual
Basic, the power of C++ and the elegance of Java
 It is intrinsically object-oriented and web-enabled
 It has a lean and consistent syntax
 It embodies today’s concern for simplicity, productivity and robustness
 It will become the language of choice for .NET programming
 Major parts of .NET Framework are actually coded in C#
C# is designed for building robust, reliable and durable components to handle real-
world applications.
Major highlights of C# are:
@ 2010 Tata McGraw-Hill Education
3
Education
WHY C#?
A large number of computer languages, starting from FORTRAN developed in
1957 to the object-oriented language Java introduced in 1995, are being used for
various applications. The choice of language depends upon many factors such as
hardware environment, business environment, user requirements and so on. The
primary motivation while developing each of these languages has been the concern
that it be able to handle the increasing complexity of programs that are robust, durable
and maintainable. The history of major languages developed during the last three
decades is given in Fig. 1.1
@ 2010 Tata McGraw-Hill Education
4
Education
@ 2010 Tata McGraw-Hill Education
5
Education
C and C++ have been the two most popular and most widely used languages in
the software industry for the past two decades. However, these languages suffer
from a number of shortcomings in meeting the emerging World Wide Web
requirements and standards. Of concern are the following:
The high complexity of the language
Their long cycle-time
They are not truly object-oriented
They are not suitable for working with
new web technologies
They have poor type-safety
They are prone to costly programming errors
They do not support versioning
They are prone to memory leakages
Their low productivity
Their poor interoperability with the
existing systems
They are weak in consistency
Their poor support for component programming
@ 2010 Tata McGraw-Hill Education
6
Education
Java, a language derived from C / C++ family, however, is truly object-oriented and has
been widely used for web applications for the past five years. Unfortunately, Java has
not retained some powerful C++ features such as operator overloading. It also lacks
inter-operability with code developed in other languages.
Microsoft wanted an environment that is completely in tune with current and
emerging Web programming practices and one that easily integrates with existing
systems. Microsoft therefore decided to design a new language starting with a clean
slate. The result is C#, a simple and modern language that directly addresses the needs
of component-based software development.
@ 2010 Tata McGraw-Hill Education
7
Education
Microsoft Chairman Bill Gates, the architect of many innovative and path-breaking
software products during the past two decades, wanted to develop a software platform
which enable users to get information anytime and anywhere, using a natural
interface.
Although the research and development work of .NET platform began in the mid-
90s, only during the Microsoft Professional Developers Conference in September
2000, was .NET officially announced to the developer community. At the same
conference, Microsoft introduced C# as a de facto language of the .NET platform. In
fact, they had already used C# to code key modules of the .NET platform. C# has
been particularly designed to build software components for .NET and it supports
key features of .NET natively. They are fairly tightly tied together. In fact, C#
compiler is embedded into .NET as shown in Fig. 1.2.
@ 2010 Tata McGraw-Hill Education
8
Education
Like Java, C# is a descendant of C++ which in turn is a descendant of C as illustrated
in Fig. 1.3. C is the mother of all the three modern languages. C# modernizes C++ by
enhancing some of its features and adding a few new features so as to help developers
do more with fewer lines of code and fewer opportunities for error.
@ 2010 Tata McGraw-Hill Education
9
Education
@ 2010 Tata McGraw-Hill Education
10
Education
CHARACTERISTICS OF C#
As pointed out earlier, the main design goal of C# was simplicity rather than pure
power. C# fulfills the need for a language that is easy to write, read and maintain
and also provides the power and flexibility of C++. The language that is designed
for both computing and communications is characterized by several key features. It
is
•Simple
•Object-oriented
•Compatible
•Consistent
•Type-safe
•Interoperable and
•Modern
•Versionable
•Flexible
@ 2010 Tata McGraw-Hill Education
11
Education
APPLICATIONS OF C#
As pointed out earlier, C# is a new language developed exclusively to suit the
features of .NET platform. It can be used for a variety of applications that are
supported by the .NET platform:
Console applications
Windows applications
Developing Windows controls
Developing ASP.NET projects
Creating Web controls
Providing Web services
Developing .NET component library
@ 2010 Tata McGraw-Hill Education
12
Education
HOW DOES C# DIFFER FROM C++?
As stated earlier, C# was derived from C++ to make it the language of
choice for C and C++ programmers. C# therefore shares major parts of
syntax with C++. However, the C# designers introduced a few changes in the
syntax of C++ and removed a few features primarily to reduce the common
pitfalls that occurred in C++ program development. They also added a
number of additional features to make C# a type-safe and web-enabled
language.
HOW DOES C# DIFFER FROM JAVA ?
Like C#, Java was also derived from C++ and therefore they have similar
roots. Moreover, C# was developed by Microsoft as an alternative to Java for
web programming. C# has borrowed many good features from Java, which
has already become a popular Internet language. However, there exist a
number of differences between C# and Java:

Characteristics of c#

  • 1.
    @ 2010 TataMcGraw-Hill Education 1 Education Introducing C#Introducing C# C #’ (pronounced as ‘C sharp’) is a new computer-programming language developed by Microsoft Corporation, USA. C# is a fully object-oriented language like Java and is the first component –oriented language. It has been designed t support the key features of .NET Framework, the new development platform of Microsoft for building component-based software solutions. It is a simple, efficient, productive and type-safe language derived from the popular C and C++ languages. Although it belongs to the family of C / C++, it is a purely objected-oriented, modern language suitable for developing Web based applications
  • 2.
    @ 2010 TataMcGraw-Hill Education 2 Education  It is a brand new language derived from the C / C++ family  It simplifies and modernizes C++  It is the only component-oriented language available today  It is the only language designed for the .NET Framework  It is a concise, lean and modern language  It combines the best features of many commonly used languages: the productivity of Visual Basic, the power of C++ and the elegance of Java  It is intrinsically object-oriented and web-enabled  It has a lean and consistent syntax  It embodies today’s concern for simplicity, productivity and robustness  It will become the language of choice for .NET programming  Major parts of .NET Framework are actually coded in C# C# is designed for building robust, reliable and durable components to handle real- world applications. Major highlights of C# are:
  • 3.
    @ 2010 TataMcGraw-Hill Education 3 Education WHY C#? A large number of computer languages, starting from FORTRAN developed in 1957 to the object-oriented language Java introduced in 1995, are being used for various applications. The choice of language depends upon many factors such as hardware environment, business environment, user requirements and so on. The primary motivation while developing each of these languages has been the concern that it be able to handle the increasing complexity of programs that are robust, durable and maintainable. The history of major languages developed during the last three decades is given in Fig. 1.1
  • 4.
    @ 2010 TataMcGraw-Hill Education 4 Education
  • 5.
    @ 2010 TataMcGraw-Hill Education 5 Education C and C++ have been the two most popular and most widely used languages in the software industry for the past two decades. However, these languages suffer from a number of shortcomings in meeting the emerging World Wide Web requirements and standards. Of concern are the following: The high complexity of the language Their long cycle-time They are not truly object-oriented They are not suitable for working with new web technologies They have poor type-safety They are prone to costly programming errors They do not support versioning They are prone to memory leakages Their low productivity Their poor interoperability with the existing systems They are weak in consistency Their poor support for component programming
  • 6.
    @ 2010 TataMcGraw-Hill Education 6 Education Java, a language derived from C / C++ family, however, is truly object-oriented and has been widely used for web applications for the past five years. Unfortunately, Java has not retained some powerful C++ features such as operator overloading. It also lacks inter-operability with code developed in other languages. Microsoft wanted an environment that is completely in tune with current and emerging Web programming practices and one that easily integrates with existing systems. Microsoft therefore decided to design a new language starting with a clean slate. The result is C#, a simple and modern language that directly addresses the needs of component-based software development.
  • 7.
    @ 2010 TataMcGraw-Hill Education 7 Education Microsoft Chairman Bill Gates, the architect of many innovative and path-breaking software products during the past two decades, wanted to develop a software platform which enable users to get information anytime and anywhere, using a natural interface. Although the research and development work of .NET platform began in the mid- 90s, only during the Microsoft Professional Developers Conference in September 2000, was .NET officially announced to the developer community. At the same conference, Microsoft introduced C# as a de facto language of the .NET platform. In fact, they had already used C# to code key modules of the .NET platform. C# has been particularly designed to build software components for .NET and it supports key features of .NET natively. They are fairly tightly tied together. In fact, C# compiler is embedded into .NET as shown in Fig. 1.2.
  • 8.
    @ 2010 TataMcGraw-Hill Education 8 Education Like Java, C# is a descendant of C++ which in turn is a descendant of C as illustrated in Fig. 1.3. C is the mother of all the three modern languages. C# modernizes C++ by enhancing some of its features and adding a few new features so as to help developers do more with fewer lines of code and fewer opportunities for error.
  • 9.
    @ 2010 TataMcGraw-Hill Education 9 Education
  • 10.
    @ 2010 TataMcGraw-Hill Education 10 Education CHARACTERISTICS OF C# As pointed out earlier, the main design goal of C# was simplicity rather than pure power. C# fulfills the need for a language that is easy to write, read and maintain and also provides the power and flexibility of C++. The language that is designed for both computing and communications is characterized by several key features. It is •Simple •Object-oriented •Compatible •Consistent •Type-safe •Interoperable and •Modern •Versionable •Flexible
  • 11.
    @ 2010 TataMcGraw-Hill Education 11 Education APPLICATIONS OF C# As pointed out earlier, C# is a new language developed exclusively to suit the features of .NET platform. It can be used for a variety of applications that are supported by the .NET platform: Console applications Windows applications Developing Windows controls Developing ASP.NET projects Creating Web controls Providing Web services Developing .NET component library
  • 12.
    @ 2010 TataMcGraw-Hill Education 12 Education HOW DOES C# DIFFER FROM C++? As stated earlier, C# was derived from C++ to make it the language of choice for C and C++ programmers. C# therefore shares major parts of syntax with C++. However, the C# designers introduced a few changes in the syntax of C++ and removed a few features primarily to reduce the common pitfalls that occurred in C++ program development. They also added a number of additional features to make C# a type-safe and web-enabled language. HOW DOES C# DIFFER FROM JAVA ? Like C#, Java was also derived from C++ and therefore they have similar roots. Moreover, C# was developed by Microsoft as an alternative to Java for web programming. C# has borrowed many good features from Java, which has already become a popular Internet language. However, there exist a number of differences between C# and Java: