Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C++ vs C#

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

C# is a general-purpose, modern and object-oriented programming language pronounced as “C sharp”. It was developed by Microsoft led by Anders Hejlsberg and his team. 
C++ is a statically typed, multiparadigm, and object-oriented programming language. In beginning, C++ was termed as C with classes. It was developed by Bjarne Stroustrup at AT & T Bell Laboratories. 

Below are some major differences between C++ and C#:

 

FeatureC++C#
Memory ManagementIn C++ memory management is performed manually by the programmer. If a programmer creates an object then he is responsible to destroy that object after the completion of that object’s task.In C# memory management is performed automatically by the garbage collector. If the programmer creates an object and after the completion of that object’s task the garbage collector will automatically delete that object.
Platform DependencyC++ code can be run on any platform. C++ is used where the application needed to directly communicate with hardware.C# code is windows specific. Although Microsoft is working to make it global but till now the major system does not provide support for C#.
Multiple InheritanceC++ support multiple inheritance through classes. Means that a class can extend more than one class at a time.C# does not support any multiple inheritances through classes.
Bound CheckingIn C++ bound checking is not performed by compiler. By mistake, if the programmer tries to access invalid array index then it will give the wrong result but will not show any compilation error.In C# bound checking in array is performed by compiler. By mistake, if the programmer tries to access an invalid array index then it will give compilation error.
PointersIn C++ pointers can be used anywhere in the program.In C# pointers can be used only in unsafe mode.
Language TypeC++ is a low level language.C# is high level object oriented language.
Level of DifficultyC++ includes very complex features.C# is quite easy because it has the well-defined hierarchy of classes.
Application TypesC++ is typically used for console applications.C# is used to develop mobile, windows, and console applications.
CompilationC++ code gets converted into machine code directly after compilation.C# code gets converted into intermediate language code after compilation.
Object OrientedC++ is not a pure object-oriented programming language due to the primitive data types.C# is a pure object-oriented programming language.
Access SpecifiersThe access modifiers are public, private, protected. It does not contain internal & protected internal access modifiers.In C# public, private, protected, internal & protected internal are used for access specifiers.
Test VariableIn switch statement, the test variable can not be a string.In switch statement, the test variable can be a string.
Control statementIt does not contain such extra flow control statement.In addition to for, while and do while; it has another flow control statement called for each.
Function PointersIt does have the concept of function pointers.It does not have the concept of function pointers.
BinariesIn C++ , size of binaries is low and lightweight.In C# , size of binaries is high because of overhead libraries.
Garbage Collection                   C++ do not support garbage collection.Garbage collection is supported by C#
Types of ProjectsIt is mainly used for such projects that focus on accessing the hardware and better performance.It is mainly used in modern application development.

 

My Personal Notes arrow_drop_up
Last Updated : 31 May, 2022
Like Article
Save Article
Related Tutorials