Comparison Between C++ and C#

If you are a C++ programmer, this summary at MSDN Library will give you the most important differences between the two languages at a glance. It also contains links to relevant details on each topic.

Besides what is listed there I find the following points worth noting in C#:
1. Support for reflection (System.Reflection)/metadata (by means of a
“manifest”)/discovery.
2. Accessors called “properties” for modifying objects.
3. Improved type-safety.
4. Local variables don’t shadow variables of the enclosing block.
5. Unified type system – all classes and primitive types are derived
from System.object .
6. Partial classes.
7. XML documentation system built into the IDE.
8. C# paradigm is object-oriented, structured and imperative. C++
paradigm is object-oriented, generic and imperative.
9. No “inheritance modes” (no public/private/protected inheritance for
classes).

Other strange things:
1. No “delete” keyword (because of automatic Garbage Collection).
2. The “new” keyword can be used in class scope.
3. Some class names exist in multiple cases (probably aliases, see the
“using” keyword), e.g.: [Oo]bject, [Ss]tring, [Dd]ouble.
4. Constructors are private by default! They need to be explicitly
specified as public.

Also related:

An excerpt from an interesting discussion about why C# interfaces can’t have static members:

Interfaces cannot contain static members because members declared in an interface are inheretly virtual since their polymorphic implementation is assumed. And a static member cannot be virtual.

Advertisements

One Response to “Comparison Between C++ and C#”

  1. Idetrorce Says:

    very interesting, but I don’t agree with you
    Idetrorce


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: