To overcome C++ pitfalls (depends on how you percieve)
1. Memory management - It's manual in C++ a headache for (mostly) new generation who can't understand the beauty of RAII. Java Garbage Collection was gaining popularity and more adoption.
2. More typesafe language than
3. Something less verbose than
C++ and Java
4. Microsoft needed something to check the growth of Java :)
I am sure people with add more :)
Great question 👍. Im just parking my comment here to hear some answers notifications and monitor.
My guess is pointers and garbage collection. But Java fixed those problems, so we could also ask why C# when there is Java?
At the time of its creation C# was very close to being a Java clone... But in 20 years they both evolved in different directions, although they sometimes adopted the same features from each other. The declared goal of C# creation was to make a modern language which solves some of the known deficiencies of C++ and Java. Originally they wanted to name it Cool (C-like Object Oriented Language) but Microsoft ditched this name for trademark reason.
Another reason I think, was that Microsoft wanted a powerful development tool to support their own software ecosystem, including ASP.NET and DOTNET, because Visual Basic did not really cut it, and they did not want to be dependent on another IT company for this (Sun Microsystems developed Java then later sold to Oracle).
Source: mostly Wikipedia.
Main advantage of C# over C++ is, dynamic programming is much simpler in C#..
For more info..
Simply, Microsoft wanted to monopolise everything. It was made to compete with Java.
Web and desktop development is done using a higher level language such as C#. C# is a part of the .Net which is especially targeted for web development, but it also works easily with a Windows-based program.
C++ is a lot more well-rounded in terms of platforms and target applications, but the developer pool is more limited since it’s not as popular for web and mobile applications. If your project is focused on extremely low-level processing, then you may need a C++ developer.