C# versus C 

If you have done some previous development on C# and C , you will realize that they follow similar code syntax, such as the use of semi-colons, and similar declarations of methods; the two languages are very different from one another. Just like in C, we can declare data variables with the same type, such as Char, and Integer. The following features make C# different from C:

Feature

C#

C

Object-oriented programming

Object-oriented programming is the main essence of any high-level programming language, and C# allows us to utilize the capabilities of OOP using the four main pillars of encapsulation, polymorphism, inheritance, and abstraction. In Chapter 3, Understanding Object-Oriented Programming, we will look at this in detail.

C as a programming language

 does not support polymorphism, encapsulation, and inheritance. 

It does not provide features such as function overloading, virtual functions, and inheritance.

Exception handling 

Exception handling is the process of handling runtime errors that occur during the execution of the application. C# provides us with exception handling features that help us handle these scenarios in a better way. In Chapter 7, Implementing Exception Handling, we will look at this in detail.

C also does not provide any exception handling features.

Type safety

Every variable declared in a program has a type. In a typical type-safe language during the program compilation stage itself, the compiler will validate the values being assigned to variables and raise a compile time error if an incorrect type is assigned to it. C# is a type-safe language. However, in Chapter 8, Creating and Using of Types in C#, we will learn that it also allows you to use pointers using a keyword, UnSafe.

C language implements type safety, albeit with some exceptions. There are certain in-built functions such as printf that do not enforce that only character strings are passed to them.

 

Let's now look at how C# compares against another language, C++. After exploring the comparison between C# and C++, we will also explore how the .NET Framework makes C# a platform-independent language compared to C and C++.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.74.160