Difference Between C++ and C# (Sharp)

In this tutorial, we will learn about the differences between C++ and C# programming languages?
By IncludeHelp Last updated : April 06, 2023

Overview

C++ programming and C# both support Object Oriented Programming approach, both are really very useful and widely used programming languages.

C++ and C# - Key Differences

There are following differences or similarities between C++ and C# are given below.

  1. C++ developed by Bjarne Stroustrup and C# developed by Anders Hejlsberg.
  2. C++ is not pure object orient language, while C# is a pure object oriented language.
  3. C++ does not support delegates, while C# uses delegates - type-safe method pointers. These are used to implement event-handling.
  4. In an important change from C++, C# code does not require header files. All code is written inline.
  5. C# has some feature derived from Visual Basic and Java but C++ is C#'s closest relative.
  6. We can use pointers in C#, that code is known as unsafe code, but they are only really useful in situations where performance gains are at an absolute premium.
  7. C# pointers are less powerful than C++. Because .NET runtime in which C# runs performs memory management takes care of tasks like garbage collection.
  8. All C# data types are ultimately derived from the object type.
  9. One important difference between C++ and C++ is, C# supports bound checking of arrays. But C++ does support bound checking of arrays.
  10. C# supports garbage collection of memory space while C++ does not support garbage collection.
  11. C# exception handling is more power compare to C++ exception handling.
  12. Generic programming is also more powerfully used in C# compare to C++.
  13. Concept of class properties used in C#. It does not supported by C++.
  14. C# statements are quite similar to C++ statements. To note just one example of a difference: the 'switch' statements have been changed so that 'fall-through' behavior is disallowed.
  15. 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 :: operator.
  16. Array declaration is different in C# compare to C and C++.
  17. C++ does not support foreach loop but C# supports foreach loop.



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.