+ 1
Differences between C++ and C#?
I would like to know why Unity uses C#. C and C++ are so similar; is C# similar too?
5 Answers
+ 7
(you should change the C tag to C++ tag)
+ 5
C# and C++ are different in every way except their names contain C
+ 2
The C# syntax is more like Java in my opinion.
+ 2
I'd have to agree and say that the C# syntax is very java-esq. C# and CPP are quite different.
For starters C# comes with a garbage collector while C++ relies heavily on you to clean up your objects. That means that every object you create a pointer to in C# is dereferenced when it no longer has any pointers leading to it. In CPP it will just sit there in memory endlessly until you end the application. Another thing is in CPP you declare your classes and methods using header files. In C# you do this directly in your C# files without any headers. C# also handles pass by reference and pass by value for you. CPP requires you to do this implicitly. In C# you can force pass by reference behaviour with the "out" and "ref" commands in your method parameters but it's different that CPP's method of passing variables.
IMHO if you are just learning try to get a solid grasp of C# and Java basic OOP concepts before dabbling in CPP. CPP is definitely an excellent language to have on your tool belt but it can be a bit much for new programmers and doesn't offer any functionality that would would be able to utilize until you start developing more complex software.
0
I am trying to get into almost any language I can so I can decide which one I love. I prefer Java. I've completed Sololearn course. I started in C++. Hence the confusion about C#.