You are on page 1of 3

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. 2. 3. 4. 5. 6. C++ is a complex language. C++ is not truly object-oriented. It is not suitable for Web technologies. It does not support versioning. It is not type-safe. 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. 2. 3. 4. 5. State the important characteristics of C#. What is meant by the phrase “C# is a type-safe language”? Define the term “versioning”. State the differences between Java and C#. State the difference s between C++ and C#.

Page 3 of 3