Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat can you do in MSIL that you cannot do in C# or VB.NET?
    text
    copied!<p>All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly?</p> <p>Let us also have things done easier in MSIL than C#, VB.NET, F#, j# or any other .NET language.</p> <p>So far we have this:</p> <ol> <li>Tail recursion</li> <li>Generic Co/Contravariance</li> <li>Overloads which differ only in return types</li> <li>Override access modifiers</li> <li>Have a class which cannot inherit from System.Object</li> <li>Filtered exceptions (can be done in vb.net)</li> <li>Calling a virtual method of the current static class type.</li> <li>Get a handle on the boxed version of a value type.</li> <li>Do a try/fault.</li> <li>Usage of forbidden names.</li> <li><a href="http://msmvps.com/blogs/jon_skeet/archive/2008/12/10/value-types-and-parameterless-constructors.aspx" rel="noreferrer">Define your own parameterless constructors for value types</a>.</li> <li>Define events with a <code>raise</code> element.</li> <li>Some conversions allowed by the CLR but not by C#.</li> <li>Make a non <code>main()</code> method as the <code>.entrypoint</code>.</li> <li>work with the native <code>int</code> and native <code>unsigned int</code> types directly.</li> <li>Play with transient pointers</li> <li>emitbyte directive in MethodBodyItem</li> <li>Throw and catch non System.Exception types</li> <li>Inherit Enums (Unverified)</li> <li>You can treat an array of bytes as a (4x smaller) array of ints.</li> <li>You can have a field/method/property/event all have the same name(Unverified).</li> <li>You can branch back into a try block from its own catch block.</li> <li>You have access to the famandassem access specifier (<code>protected internal</code> is fam<strong>or</strong>assem)</li> <li>Direct access to the <code>&lt;Module&gt;</code> class for defining global functions, or a module initializer.</li> </ol>
 

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