Home » .Net

Differences between C++ and C#

Learn: What are the differences between C++ programming language and C# programming? Both are the widely used programming languages, they have following differences.

C++ programming and C# both support Object Oriented Programming approach, both are really very useful and widely used programming languages, here we will learn the differences between C++ and C#.

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!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.