views:

168

answers:

4

So, I am a C/C++ programmer currently in development of a small win32 project. I was told that C++ was becoming outdated, to be replaced with C#. This was over two years ago.

So in your opinion, is C# a significant step up from C++, and does it provide more features/ease of use/ect.. that would make it worthwhile to learn.

How much of my C++ code would I have to change if I were to use C#. Would there be any major changes that I would need to make.

And finally, how different are the standard libraries?

Oh, and what is the prefix? (e.g. .c, .cpp, .?)

A: 

Following tow feature are more important to learn

Pranay Rana
huh? how is that a comparison of features between C++ to C#?
RPM1984
I've got to disagree with this. Coming from a C++ background things like garbage collection, no pointers, difference in structs, everything is polymorphic (from object) etc are far more important. Understanding how to query a collection via SQL like syntax wouldn't be high on my list of things to learn, nor would generics (whilst quite different in implementation and usage, the concept is similar to templates).
Michael Shimmins
Are these related to .net? I am not using .net.
Alexander Rafferty
If you're developing in C# you will be using .NET.
Michael Shimmins
@Michael Shimmins - what about XNA? =) (you're right though, he will be using .NET), but i enjoy nitpicking sometimes. =)
RPM1984
@RPM1984 - what about it? :) 'The XNA Framework is based on the native implementation of .NET Compact Framework 2.0 for Xbox 360 development and .NET Framework 2.0 on Windows.' http://en.wikipedia.org/wiki/Microsoft_XNA
Michael Shimmins
@Michael Shimmins. You win. =)
RPM1984
+1  A: 

There is a lot of material on internet but for you to start using C# best place is the compare with c++

so http://msdn.microsoft.com/en-us/library/yyaad03b(VS.71).aspx

this link gives you some basic idea

saurabh
That will be a lot of reading.
Alexander Rafferty
+3  A: 

C++ and C# are completely different languages with completely different API and libraries. They share some syntactic conventions at the low level (e.g. basic control structures look mostly the same), and C# is certainly in the C "family", but beyond that they're not terribly similar.

You're not just going to be able to throw your C++ code at a C# compiler with a few modifications. Depending on how much of C++ you use, you may or may not even be able to do a class-by-class port manually. Most notably, C# generics are less powerful than C++ templates, C# lacks multiple inheritance, and C# does not provide predictable object lifecycle for all objects.

The most salient features of C# are the large and featureful standard library, the garbage collector, anonymous methods, and language level support for some standard patterns (e.g. IEnumerable is supported by foreach and linq, IDisposable is supported by using, ...). Day-to-day, these things make a huge difference.

It's completely worthwhile to learn. While C++ provides more control over low-level details, often provides more predictable performance, and has more powerful metaprogramming facilities (templates, c style macros), for most of the code you write day-to-day, C# will make you more productive.

The filename extension for C# is usually .cs.

blucz
+1  A: 

Almost all of the code would change - you wouldn't be able to port one across.

C# is a managed language, which means it takes care of memory allocation and deallocation for you (with some exceptions), through the use of the garbage collector.

You don't use pointers (unless in unsafe mode).

C# files have the .cs extension.

The .NET environment (be in in C#, VB.NET or managed C++) is a good option for developing desktop applications, and is generally easier and quicker to work with than C++.

Some applications benefit significantly from a C++ implementation, especially is multi-platform execution is important, or performance is a significant requirement (don't confuse this statement as me saying C# doesn't perform well, it does, and for most applications is perfectly suited).

Michael Shimmins