1

NOTE: Just want to clarify if my current understanding is correct after I came across a MSDN doc which seems to contradicts another MSDN doc. Also I have already been through the following links -

  1. Is C# unsafe code managed?
  2. What is difference between unsafe code and unmanaged code in C#

I had the following understanding (which I developed after going through this link):

Managed code: Code written in one of the high-level languages (that can be run on top of .NET such as C#, F# and others) upon compilation generates IL whose execution is managed and supervised by a runtime (in this case CLR, regardless of the implementation for e.g. Mono, .NET Framework, .NET Core/.NET 5+) is called managed code.

IL: It is a product of compilation of managed code.

But then I came across this link, according to which it says: When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL)... and so on.

Both documentations are from MSDN, and not sure if it is a typo, thus the question.

So which one is correct?

phougatv
  • 881
  • 2
  • 12
  • 29
  • Managed code means that you don't have to take special care to free up managed memory it is done on your behalf by the runtime which calls the Garbage Collector whenever it thinks it is appropriate. – Peter Csala Feb 21 '22 at 13:39
  • The IL code simplifies the runtime's job since it has to only understand IL not C#, VB, and F#... So why do you think that they are contradict each other? – Peter Csala Feb 21 '22 at 13:41
  • @PeterCsala Contradiction is when one document says: **_compiling to managed code..._** and another saying: **_Managed code is written in one of the high-level languages that can be run on top of .NET, such as C#, Visual Basic, F# and others_**. – phougatv Feb 21 '22 at 14:01
  • 1
    C#, VB, F# and IL code are all managed. So compiling to managed code is valid, but it really means compilation to MSIL. – Peter Csala Feb 21 '22 at 14:05
  • Shall I leave a post to be able to close your question? – Peter Csala Feb 21 '22 at 14:13
  • @PeterCsala My apologies, I couldn't reply. I think I get the picture now, I took the documentation too literally. :) – phougatv Feb 21 '22 at 14:39

0 Answers0