问题
I know that Java code is compiled into byte-code, that is executed by the JVM.
What is the case with C# ? I have noticed that applications written in C# have the .exe
extension what would suggest they are native machine instructions. but is it really so ?
回答1:
No.
Like Java, C# is compiled to an intermediary language (called MSIL or CIL).
Unlike Java, the IL is stored in EXE files which have enough actual EXE code to show a dialog box asking users to install .Net.
回答2:
C# compilation is done in these two steps :
1. Conversion from C# to CIL by the C# compiler
2. Conversion from CIL to instructions that the processor can execute.
A component (just in time) performs this compilation at run time from CIL to machine code
回答3:
What that .exe is supposed to tell you is that the file is executable. C# is compiled into bytecode, just as java is, but .NET wraps this in a CLR executable.
Look here for a more in depth look at CLR executable http://etutorials.org/Programming/.NET+Framework+Essentials/Chapter+2.+The+Common+Language+Runtime/2.2+CLR+Executables/
回答4:
c# code is compiled to MSIL. it likes java bytecode. msil will be convert to machine isntrctions at runtime.
回答5:
C# code is compiled to MSIL, MSIL is taken care by .NET CLR
来源:https://stackoverflow.com/questions/12583514/is-c-sharp-code-compiled-to-native-binaries