Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>C++/CLI has a few interesting things that C# does not have:</p> <ul> <li><p>Strongly-typed boxing. If you box an <code>int</code> to an <code>object</code> in C#, you lose any information about what the original type was. Not the case in C++/CLI.</p></li> <li><p>A distinction between destructors and finalizers. In C# you have to manually implement <code>IDisposable</code> and remember to call <code>Dispose</code>. In C++/CLI, you just chuck the cleanup code in the destructor (which automatically gets compiled into a <code>Dispose</code> method), and put the managed-only cleanup code in the finalizer.</p></li> <li><p>A distinction between stack and heap semantics for variables. Stack is the default, and stack-allocated reference types will <strong>automatically</strong> be destroyed (disposed) - you don't have to remember to <code>delete</code> them, just let them go out of scope. To make a long story short, it's a lot easier to deal with unmanaged resources in C++/CLI than any other .NET language.</p></li> <li><p>Function pointers. This is less of a distinction now with anonymous delegates and lambda syntax in C#, but back in 2005 this was kind of a big deal.</p></li> <li><p>Access to <strong>all</strong> of the access modifiers implemented in the CLR. You can explicitly specify public, protected or private for both the same assembly <em>and</em> external assemblies. All you have in C# (other than the obvious <code>public</code>, <code>protected</code>, <code>private</code>) are the <code>internal</code> and <code>protected internal</code> modifiers, the former meaning "public internally, private externally" and the latter meaning "public internally, protected externally". In C++ you can make a class "protected AND internal", which means that the member is only accessible to derived classes in the <em>same</em> assembly.</p></li> <li><p>Value classes. Weird, but probably useful to someone!</p></li> </ul> <p>There's a more detailed explanation of all this and more <a href="http://msdn.microsoft.com/en-us/library/ms379617(VS.80).aspx" rel="noreferrer">here</a>. To make a long story short, other managed languages - C#, VB.NET, F#, and so on - do not actually give you full access to everything that the CLR can do, more like 90% of it. C++/CLI lets you do pretty much anything you want that's in the CLR spec.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload