There are several interesting things in C ++ / CLI that C # doesn't have:
Strongly typed box. If you set int to object in C #, you will lose any information about what the original type is. Not in C ++ / CLI.
The difference between destructors and finalizers. In C #, you need to manually implement IDisposable and don't forget to call Dispose . In C ++ / CLI, you simply drop the cleanup code in the destructor (which is automatically compiled into the Dispose method) and put the cleanup code for control only in the finalizer.
The difference between stack and heap semantics for variables. Stack is standard, and the reference types associated with the stack will be automatically destroyed (deleted) - you do not need to remember delete them, just release them from the scope. In short, it's much easier to handle unmanaged resources in C ++ / CLI than any other .NET language.
Function pointers. Now this is less of a difference with anonymous delegates and lambda syntax in C #, but back in 2005 it was something more.
Access to all access modifiers implemented in the common language runtime. You can explicitly specify public, protected or private both for one assembly and for external assemblies. All you have in C # (except for the obvious public , protected , private ) is the internal and protected internal modifiers, the first of which means "publicly internally, private from the outside," and the latter means "publicly accessible, protected from the outside." In C ++, you can make the class "protected AND internal", which means that the member is only available for derived classes in the same assembly.
Value classes Strange, but probably helpful to someone!
Here is a more detailed explanation of all this and more here . In short, other managed languages ββare C #, VB.NET, F #, etc. - In fact, they do not give you full access to everything that the CLR can do, more than 90%. C ++ / CLI allows you to do almost everything you need in the CLR specification.
source share