Can hand-written CIL do what C # cannot?

So this is a pretty simple question, but I don't see the answer anywhere.

If I somehow create the CIL code manually, is it possible to do something that would be forbidden in C #? Which things? (Obviously, I do not expect an exhaustive list.)

I did not know much about the fine details of CIL. But, given that the CLR should be linguistic agnostic, but maintain a tight connection between components written in different languages, I would expect CIL to work at the object level and possibly have its own type system. I can imagine that the type system is less rigid than C #, and maybe a few other things that can be different. But I was wondering if anyone knows completely without reading the entire language specification ...

+4
source share
1 answer

Of course. Nothing that allows you to perform tasks that are impossible for C # code (Turing-completeness, etc.), but there are programming constructs that are not currently displayed in C #. Please note that some of them have been added for the upcoming C # 6.

Most likely, not a complete list, above:

  • try .. fault. They are executed only when the block tryleaves the exception.
  • Exceptional filters. VB already have them, and the C # 6 will also have them: catch .. when.
  • Constructors (value types) without parameters. C # 6 will have them. EDIT: svick commented that the function was removed.
  • General type constraint on enum.
  • A protected internal ( , ).

, .

+2

All Articles