+ 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?

30th Nov 2017, 9:34 AM
Rizan
Rizan - avatar
6 odpowiedzi
+ 7
(you should change the C tag to C++ tag)
2nd Dec 2017, 7:08 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 5
C# and C++ are different in every way except their names contain C
30th Nov 2017, 9:45 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
The C# syntax is more like Java in my opinion.
30th Nov 2017, 9:37 AM
Lucien
Lucien - avatar
+ 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.
30th Nov 2017, 9:54 AM
Scatoogle
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#.
30th Nov 2017, 10:44 AM
Rizan
Rizan - avatar