SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
Generated by Foxit PDF Creator © Foxit Software
                                                 http://www.foxitsoftware.com For evaluation only.




                           1. INTRODUCTION TO C#
C#, pronounced as C sharp, is a computer language used to give instructions that tell the computer
what to do, how to do it, and when to do it. C# is one of the languages used in the Microsoft .NET
Framework.

You can program in C# by using Visual C# 2005 Express Edition, which is available as a free
download from the Microsoft Web site at http://msdn.microsoft.com/express/default.aspx


Features of C# :
1. Object-oriented language.
        a. C# supports the three most important features of OOP i.e., Polymorphism, Inheritance, and
            Encapsulation. (PIE). In C#, everything is an object.
        b. There are no global functions, variables and constants.
2. Simple : C# is a simple language.
        a. It does not support the complicated features of C++ such as pointers, scope resolution
            operator (::)
        b. Macros and templates are not supported in C# as these features cause errors in programs.
        c. C++ has three different symbols for working with members: the (.) operator, the (:: )
            operator and the -> operator. In C#, all these are replaced by the dot operator (.).
3. Modern: C# is a modern language. It supports the features of
        a. garbage collection,
        b. code security,
        c. error handling features,
        d. new approach to debugging,.
4. C# is type-safe: It means the following:
        a. C# arrays are bound unlike arrays in C and C++.
        b. If uninitialized arrays are used, the compiler produces an error.
        c. C# supports automatic garbage collection. Garbage collection is a form of automatic
            memory management. The garbage collector tries to free the memory used by objects, that
            will never be accessed again by the application.
        d. C# enforces overflow checking in arithmetic operations.
        e. All dynamically objects and arrays are initialized to zero. (In C, uninitialized variables have
            junk value).
5. It has the best features of C++, Visual Basic and Java.
6. It is a component-oriented language.
7. It is derived from C & C++ languages. So it is easy to learn. Syntax is similar to that of C and C++
8. Web-enabled : It is Web-enabled i.e. suitable for Web applications.
9. .NET Framework : It has been designed to support the .NET Framework.


                                               Page 1 of 3
Generated by Foxit PDF Creator © Foxit Software
                                                 http://www.foxitsoftware.com For evaluation only.




Prof. Mukesh N. Tekwani                                         Email: mukeshtekwani@hotmail.com
10. C# is powerful and flexible: It can be used for diverse projects such as word-processors, graphics
    applications, spreadsheets, windows applications, and compilers for other languages.
11. Versionable: Versioning means the creation and management of multiple versions of a software.
    All versions have the same general function but they are improved, upgraded or customized. New
    versions of software modules can work with existing applications. C# supports versioning with the
    keywords called new and override.
12. Compatible: C# enforces the .NET common language specifications and allows inter operation
    with other .NET languages such as VB .NET.


Shortcomings / Drawbacks of C++:
1.   C++ is a complex language.
2.   C++ is not truly object-oriented.
3.   It is not suitable for Web technologies.
4.   It does not support versioning.
5.   It is not type-safe.
6.   C++ supports pointers which can result in major errors in programs.



Differences between C# and C++ :

Although C# is derived from C++, there are many differences between these two languages. These are:
1. C# does not support the #include statement.
2. C# does not support pointer types.
3. C# supports a native Boolean data type.
4. The entry point of both C# and C++ programs is a main method. In C#, the main method is written
    as Main (beginning with capital M), while in C++, the main method is written as main (starting
    with small m).
5. C# supports four iteration statements rather than three in C++. The fourth statement is called
    foreach.
6. C# can check overflow of arithmetic operations and conversions.
7. C# compiles from source code to object code. Object files are not produced.
8. All basic value types will have the same size on any system. This is not the case with C or C++.
    Therefore C# is more suitable for writing distributed applications.
9. C# checks for uninitialized variables and gives error messages at compile time. In C++, an
    uninitialized variable is not detected and causes errors in the output.
10. Arrays are classes in C# and operations such as sorting, reversing, and searching can be carried out.
11. Type casting in C# is safer than in C++.
12. C# does not allow silent fall through in switch statements. We must give an explicit jump statement
    at the end of each case statement.



                                              Page 2 of 3
Generated by Foxit PDF Creator © Foxit Software
                                                http://www.foxitsoftware.com For evaluation only.




                                                                                  1. Introduction to C#
13. Accidental use of the assignment operator (=), instead of the equality operator (==) will be caught
    by the compiler.
14. In C#, the switch statement can also be used on string values.
15. There is less need for destructors as garbage collection is automatic.
16. In C#, Boolean values cannot be treated as integers.
17. C# supports a native string type.



Differences between C# and Java :

Java was also based on C++ and hence C# and Java have many common features. C# was developed as
an alternative to Java. The differences between C# and Java are as follows:
1. In C#, all data types are objects.
2. C# has more primitive data types.
3. The entry point of both C# and Java programs is a main method. In C#, the main method is written
    as Main (beginning with capital M), while in Java, the main method is written as main (starting
    with small m).
4. C# supports the struct type but Java does not support it.
5. Java does not support operator overloading.
6. In C#, the switch statement supports either integer or string expressions, but Java supports only
    integer expressions.
7. Java does not directly support enumeration.
8. C# has native support for properties but Java does not have it.
9. Constants are declared in C# by using the const keyword. But in Java, constants are used by using
    the final keyword.
10. C# has a new primitive data type called decimal which stores decimal numbers without rounding
    errors. This is useful for financial applications.
11. C# provides better versioning support than Java.
12. C# provides static constructors for initialization.
13. C# allows parameters to be passed by reference but Java permits parameters to be passed by value.
14. C# does not allow free fall-through from case to case.



IMPORTANT QUESTIONS

1.   State the important characteristics of C#.
2.   What is meant by the phrase “C# is a type-safe language”?
3.   Define the term “versioning”.
4.   State the differences between Java and C#.
5.   State the difference s between C++ and C#.


                                              Page 3 of 3

Weitere ähnliche Inhalte

Was ist angesagt?

CSharp difference faqs- 1
CSharp difference faqs- 1CSharp difference faqs- 1
CSharp difference faqs- 1Umar Ali
 
introduction to c language
 introduction to c language introduction to c language
introduction to c languageRai University
 
Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C LanguageKamal Acharya
 
Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C LanguageTarun Sharma
 
Introduction to c_language
Introduction to c_languageIntroduction to c_language
Introduction to c_languageWay2itech
 
C programming language Reference Note
C programming language Reference NoteC programming language Reference Note
C programming language Reference NoteChetan Thapa Magar
 
C Programming language - introduction
C Programming  language - introduction  C Programming  language - introduction
C Programming language - introduction GopikaS12
 
Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)John Smith
 
Training report of C language
Training report of C languageTraining report of C language
Training report of C languageShashank Kapoor
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
6 Week C++ Language Training In Ambala
6 Week C++ Language Training In Ambala6 Week C++ Language Training In Ambala
6 Week C++ Language Training In AmbalaBatra Computer Centre
 
Objective-C with respect to C# and Java
Objective-C with respect to C# and JavaObjective-C with respect to C# and Java
Objective-C with respect to C# and JavaBabul Mirdha
 
Programming Methodology
Programming MethodologyProgramming Methodology
Programming Methodologyarchikabhatia
 

Was ist angesagt? (19)

C#.NET
C#.NETC#.NET
C#.NET
 
CSharp difference faqs- 1
CSharp difference faqs- 1CSharp difference faqs- 1
CSharp difference faqs- 1
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
C language
C languageC language
C language
 
Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C Language
 
C vs c++
C vs c++C vs c++
C vs c++
 
Introduction to C Language
Introduction to C LanguageIntroduction to C Language
Introduction to C Language
 
C language part 1
C language part  1C language part  1
C language part 1
 
Introduction to C# Programming
Introduction to C# ProgrammingIntroduction to C# Programming
Introduction to C# Programming
 
Introduction to c_language
Introduction to c_languageIntroduction to c_language
Introduction to c_language
 
C programming language Reference Note
C programming language Reference NoteC programming language Reference Note
C programming language Reference Note
 
C Programming language - introduction
C Programming  language - introduction  C Programming  language - introduction
C Programming language - introduction
 
Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)
 
C Language
C LanguageC Language
C Language
 
Training report of C language
Training report of C languageTraining report of C language
Training report of C language
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
6 Week C++ Language Training In Ambala
6 Week C++ Language Training In Ambala6 Week C++ Language Training In Ambala
6 Week C++ Language Training In Ambala
 
Objective-C with respect to C# and Java
Objective-C with respect to C# and JavaObjective-C with respect to C# and Java
Objective-C with respect to C# and Java
 
Programming Methodology
Programming MethodologyProgramming Methodology
Programming Methodology
 

Andere mochten auch

C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014FalafelSoftware
 
Formation C# & XAML
Formation C# & XAML Formation C# & XAML
Formation C# & XAML Hiba GHADHAB
 
Comparing xaml and html
Comparing xaml and htmlComparing xaml and html
Comparing xaml and htmlKevin DeRudder
 
Build your own Cloud/Home security system for 60$
Build your own Cloud/Home security system for 60$Build your own Cloud/Home security system for 60$
Build your own Cloud/Home security system for 60$Kevin DeRudder
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpAbefo
 
C# 3.0 and 4.0
C# 3.0 and 4.0C# 3.0 and 4.0
C# 3.0 and 4.0Buu Nguyen
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Xamarin
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course IntroductionIntro C# Book
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 

Andere mochten auch (18)

C#
C#C#
C#
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
C sharp chap6
C sharp chap6C sharp chap6
C sharp chap6
 
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014XAML Development with Xamarin  - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
 
Formation C# & XAML
Formation C# & XAML Formation C# & XAML
Formation C# & XAML
 
Comparing xaml and html
Comparing xaml and htmlComparing xaml and html
Comparing xaml and html
 
Build your own Cloud/Home security system for 60$
Build your own Cloud/Home security system for 60$Build your own Cloud/Home security system for 60$
Build your own Cloud/Home security system for 60$
 
Formation VB.NET
Formation VB.NETFormation VB.NET
Formation VB.NET
 
C#
C#C#
C#
 
Agile Retrospectives
Agile RetrospectivesAgile Retrospectives
Agile Retrospectives
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
 
C# 3.0 and 4.0
C# 3.0 and 4.0C# 3.0 and 4.0
C# 3.0 and 4.0
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course Introduction
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Ppt of c vs c#
Ppt of c vs c#Ppt of c vs c#
Ppt of c vs c#
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 

Ähnlich wie C sharp chap1

Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docxLenchoMamudeBaro
 
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)ssuser7f90ae
 
Migrating From Cpp To C Sharp
Migrating From Cpp To C SharpMigrating From Cpp To C Sharp
Migrating From Cpp To C SharpGanesh Samarthyam
 
programming in c#.ppt
programming in c#.pptprogramming in c#.ppt
programming in c#.pptNalinaKumari2
 
Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Wes Yanaga
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionAKR Education
 
C and C ++ Training in Ambala ! BATRA COMPUTER CENTRE
C and C ++ Training in Ambala ! BATRA COMPUTER CENTREC and C ++ Training in Ambala ! BATRA COMPUTER CENTRE
C and C ++ Training in Ambala ! BATRA COMPUTER CENTREjatin batra
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkDr.Neeraj Kumar Pandey
 
C++ vs java which is best for future
C++ vs java which is best for futureC++ vs java which is best for future
C++ vs java which is best for futurecalltutors
 

Ähnlich wie C sharp chap1 (20)

Programming with c#
Programming with c#Programming with c#
Programming with c#
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
 
C-sharping.docx
C-sharping.docxC-sharping.docx
C-sharping.docx
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
 
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
 
C#
C#C#
C#
 
Migrating From Cpp To C Sharp
Migrating From Cpp To C SharpMigrating From Cpp To C Sharp
Migrating From Cpp To C Sharp
 
programming in c#.ppt
programming in c#.pptprogramming in c#.ppt
programming in c#.ppt
 
Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)Intro to c# (vs. objective c and java)
Intro to c# (vs. objective c and java)
 
Presentation1
Presentation1Presentation1
Presentation1
 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
 
C# handout.docx
C# handout.docxC# handout.docx
C# handout.docx
 
C and C ++ Training in Ambala ! BATRA COMPUTER CENTRE
C and C ++ Training in Ambala ! BATRA COMPUTER CENTREC and C ++ Training in Ambala ! BATRA COMPUTER CENTRE
C and C ++ Training in Ambala ! BATRA COMPUTER CENTRE
 
C#
C#C#
C#
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net Framework
 
Programming
ProgrammingProgramming
Programming
 
C++ vs java which is best for future
C++ vs java which is best for futureC++ vs java which is best for future
C++ vs java which is best for future
 
Tutorial csharp
Tutorial csharpTutorial csharp
Tutorial csharp
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
 

Mehr von Mukesh Tekwani

Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelComputer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelMukesh Tekwani
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfThe Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfMukesh Tekwani
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics  -  PhysicsISCE-Class 12-Question Bank - Electrostatics  -  Physics
ISCE-Class 12-Question Bank - Electrostatics - PhysicsMukesh Tekwani
 
Hexadecimal to binary conversion
Hexadecimal to binary conversion Hexadecimal to binary conversion
Hexadecimal to binary conversion Mukesh Tekwani
 
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Mukesh Tekwani
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversionMukesh Tekwani
 
Gray code to binary conversion
Gray code to binary conversion Gray code to binary conversion
Gray code to binary conversion Mukesh Tekwani
 
Decimal to Binary conversion
Decimal to Binary conversionDecimal to Binary conversion
Decimal to Binary conversionMukesh Tekwani
 
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Mukesh Tekwani
 
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prismRefraction and dispersion of light through a prism
Refraction and dispersion of light through a prismMukesh Tekwani
 
Refraction of light at a plane surface
Refraction of light at a plane surfaceRefraction of light at a plane surface
Refraction of light at a plane surfaceMukesh Tekwani
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomAtom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomMukesh Tekwani
 
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesRefraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesMukesh Tekwani
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEMukesh Tekwani
 

Mehr von Mukesh Tekwani (20)

Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelComputer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube Channel
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfThe Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdf
 
Circular motion
Circular motionCircular motion
Circular motion
 
Gravitation
GravitationGravitation
Gravitation
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics  -  PhysicsISCE-Class 12-Question Bank - Electrostatics  -  Physics
ISCE-Class 12-Question Bank - Electrostatics - Physics
 
Hexadecimal to binary conversion
Hexadecimal to binary conversion Hexadecimal to binary conversion
Hexadecimal to binary conversion
 
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Hexadecimal to decimal conversion
Hexadecimal to decimal conversion
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversion
 
Gray code to binary conversion
Gray code to binary conversion Gray code to binary conversion
Gray code to binary conversion
 
What is Gray Code?
What is Gray Code? What is Gray Code?
What is Gray Code?
 
Decimal to Binary conversion
Decimal to Binary conversionDecimal to Binary conversion
Decimal to Binary conversion
 
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21
 
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prismRefraction and dispersion of light through a prism
Refraction and dispersion of light through a prism
 
Refraction of light at a plane surface
Refraction of light at a plane surfaceRefraction of light at a plane surface
Refraction of light at a plane surface
 
Spherical mirrors
Spherical mirrorsSpherical mirrors
Spherical mirrors
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomAtom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atom
 
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesRefraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lenses
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
 
Cyber Laws
Cyber LawsCyber Laws
Cyber Laws
 
XML
XMLXML
XML
 

C sharp chap1

  • 1. Generated by Foxit PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. 1. INTRODUCTION TO C# C#, pronounced as C sharp, is a computer language used to give instructions that tell the computer what to do, how to do it, and when to do it. C# is one of the languages used in the Microsoft .NET Framework. You can program in C# by using Visual C# 2005 Express Edition, which is available as a free download from the Microsoft Web site at http://msdn.microsoft.com/express/default.aspx Features of C# : 1. Object-oriented language. a. C# supports the three most important features of OOP i.e., Polymorphism, Inheritance, and Encapsulation. (PIE). In C#, everything is an object. b. There are no global functions, variables and constants. 2. Simple : C# is a simple language. a. It does not support the complicated features of C++ such as pointers, scope resolution operator (::) b. Macros and templates are not supported in C# as these features cause errors in programs. c. C++ has three different symbols for working with members: the (.) operator, the (:: ) operator and the -> operator. In C#, all these are replaced by the dot operator (.). 3. Modern: C# is a modern language. It supports the features of a. garbage collection, b. code security, c. error handling features, d. new approach to debugging,. 4. C# is type-safe: It means the following: a. C# arrays are bound unlike arrays in C and C++. b. If uninitialized arrays are used, the compiler produces an error. c. C# supports automatic garbage collection. Garbage collection is a form of automatic memory management. The garbage collector tries to free the memory used by objects, that will never be accessed again by the application. d. C# enforces overflow checking in arithmetic operations. e. All dynamically objects and arrays are initialized to zero. (In C, uninitialized variables have junk value). 5. It has the best features of C++, Visual Basic and Java. 6. It is a component-oriented language. 7. It is derived from C & C++ languages. So it is easy to learn. Syntax is similar to that of C and C++ 8. Web-enabled : It is Web-enabled i.e. suitable for Web applications. 9. .NET Framework : It has been designed to support the .NET Framework. Page 1 of 3
  • 2. Generated by Foxit PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. Prof. Mukesh N. Tekwani Email: mukeshtekwani@hotmail.com 10. C# is powerful and flexible: It can be used for diverse projects such as word-processors, graphics applications, spreadsheets, windows applications, and compilers for other languages. 11. Versionable: Versioning means the creation and management of multiple versions of a software. All versions have the same general function but they are improved, upgraded or customized. New versions of software modules can work with existing applications. C# supports versioning with the keywords called new and override. 12. Compatible: C# enforces the .NET common language specifications and allows inter operation with other .NET languages such as VB .NET. Shortcomings / Drawbacks of C++: 1. C++ is a complex language. 2. C++ is not truly object-oriented. 3. It is not suitable for Web technologies. 4. It does not support versioning. 5. It is not type-safe. 6. C++ supports pointers which can result in major errors in programs. Differences between C# and C++ : Although C# is derived from C++, there are many differences between these two languages. These are: 1. C# does not support the #include statement. 2. C# does not support pointer types. 3. C# supports a native Boolean data type. 4. The entry point of both C# and C++ programs is a main method. In C#, the main method is written as Main (beginning with capital M), while in C++, the main method is written as main (starting with small m). 5. C# supports four iteration statements rather than three in C++. The fourth statement is called foreach. 6. C# can check overflow of arithmetic operations and conversions. 7. C# compiles from source code to object code. Object files are not produced. 8. All basic value types will have the same size on any system. This is not the case with C or C++. Therefore C# is more suitable for writing distributed applications. 9. C# checks for uninitialized variables and gives error messages at compile time. In C++, an uninitialized variable is not detected and causes errors in the output. 10. Arrays are classes in C# and operations such as sorting, reversing, and searching can be carried out. 11. Type casting in C# is safer than in C++. 12. C# does not allow silent fall through in switch statements. We must give an explicit jump statement at the end of each case statement. Page 2 of 3
  • 3. Generated by Foxit PDF Creator © Foxit Software http://www.foxitsoftware.com For evaluation only. 1. Introduction to C# 13. Accidental use of the assignment operator (=), instead of the equality operator (==) will be caught by the compiler. 14. In C#, the switch statement can also be used on string values. 15. There is less need for destructors as garbage collection is automatic. 16. In C#, Boolean values cannot be treated as integers. 17. C# supports a native string type. Differences between C# and Java : Java was also based on C++ and hence C# and Java have many common features. C# was developed as an alternative to Java. The differences between C# and Java are as follows: 1. In C#, all data types are objects. 2. C# has more primitive data types. 3. The entry point of both C# and Java programs is a main method. In C#, the main method is written as Main (beginning with capital M), while in Java, the main method is written as main (starting with small m). 4. C# supports the struct type but Java does not support it. 5. Java does not support operator overloading. 6. In C#, the switch statement supports either integer or string expressions, but Java supports only integer expressions. 7. Java does not directly support enumeration. 8. C# has native support for properties but Java does not have it. 9. Constants are declared in C# by using the const keyword. But in Java, constants are used by using the final keyword. 10. C# has a new primitive data type called decimal which stores decimal numbers without rounding errors. This is useful for financial applications. 11. C# provides better versioning support than Java. 12. C# provides static constructors for initialization. 13. C# allows parameters to be passed by reference but Java permits parameters to be passed by value. 14. C# does not allow free fall-through from case to case. IMPORTANT QUESTIONS 1. State the important characteristics of C#. 2. What is meant by the phrase “C# is a type-safe language”? 3. Define the term “versioning”. 4. State the differences between Java and C#. 5. State the difference s between C++ and C#. Page 3 of 3