Does C# compile to an exe?

This is a discussion on Does C# compile to an exe? within the C# Programming forums, part of the General Programming Boards category; I'm a noob to C#. Does C# compile to an executable .exe file the way that C++ does? I understand ...

Does C# compile to an exe?

I'm a noob to C#. Does C# compile to an executable .exe file the way that C++ does? I understand that it compiles to byte code like Java, but I wasn't sure if I had to type something like "ms-csharp my_prog.class" in order to run it.

Also, is it possible to compile C# to a .DLL file in a way similar to C++?

Not like C++ does, but to an executable that the CLR can understand. MIL, microsoft intermediate language. Each method call is Jittered (JIT) or just in time compiled before it executes. So in order for a computer to run this it will need the .Net framework installed on the machine, luckily this is most modern microsoft machines. This is similar to the java runtime in a sense.

To a user though, as long as they have the framework installed, the executable is transparent to what language it was written in and behaves like a normal program.

Yes. But the executable code contained in it does not contain the instructions that do what the C# code does, not in the format the specified cpu architecture can understand at least. The code stored in the executable is run by the CLR, but yes, it does compile to an executable.

No, it is not possible to compile C# so that it can run without the framework installed. C# only half compiles, the final compilation is done by the framework at runtime. This is both a good feature and a security risk. It is good because in theory as new processor technologies become available and the framework is updated, your existing applications will take advantage of these if possible. It is a security risk because anyone that makes half an effort can extract your source code from the executable.

Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

No, it is not possible to compile C# so that it can run without the framework installed. C# only half compiles, the final compilation is done by the framework at runtime. This is both a good feature and a security risk. It is good because in theory as new processor technologies become available and the framework is updated, your existing applications will take advantage of these if possible. It is a security risk because anyone that makes half an effort can extract your source code from the executable.