C Sharp vs C Plus Plus

Highlight the difference between c sharp and c plus plus.

 

C# versus C++

Although it has some elements derived from Visual Basic and Java, C++ is C#'s closest relative.

In an important change from C++, C# code does not require header files. All code is written inline.

As touched on above, the .NET runtime in which C# runs performs memory management, taking care of tasks like garbage collection. Because of this, the use of pointers in C# is much less important than in C++. Pointers can be used in C#, where the code is marked as 'unsafe', but they are only really useful in situations where performance gains are at an absolute premium.

Speaking generally, the 'plumbing' of C# types is different from that of C++ types, with all C# types being ultimately derived from the 'object' type. There are also specific differences in the way that certain common types can be used. For instance, C# arrays are bounds checked unlike in C++, and it is therefore not possible to write past the end of a C# array.

C# statements are quite similar to C++ statements. To note just one example of a difference: the 'switch' statement has been changed so that 'fall-through' behavior is disallowed.

As mentioned above, C# gives up on the idea of multiple class inheritance. Other differences relating to the use of classes are: there is support for class 'properties' of the kind found in Visual Basic, and class methods are called using the Operator rather than the :: operator.

Leave Comment

Important Topics

Title
Terminologies in C Sharp
Introduction to C Sharp
Hello World Program
C vs C Sharp
C Sharp vs C Plus Plus
C SHARP vs JAVA
Array and Types of Array
Programs - Sum of all numbers in Array
Strings and Types of Strings
Delegates in C sharp
System Collection Generic
System.Collections Classes
System.Collections.Concurrent
Dot Net Assembly
Events in C Sharp