Where to write C# code:

You can write C# code in Visual studio or use C# online compiler . tip: Visual studio comes with different licenses and some of its components (Visual studio express for web etc..) are free.

Compilation and execution:

1.After writing code in visual studio click on F6 (or) Build solution option. which sends code to C# compiler.
2.C# compiler verifies C# code (it checks whether C# code written by programmer is following all the C# rules are not if not C# compiler punish the programmer by sending an error ).
3.Some of the C# language rules are given below.
a.Every class/Struct/Interface/Enum must start with Curly bracket and must end with curly bracket.
b.Every method in C# must have parentheses (except anonymous methods).
c.Every method in C# must have starting and ending curly brackets.
d.Every statement in C# must end with a semi colon.
4.If C# program following all C# language rules then C# compiler converts C# code into MSIL Code ( MSIL stands for microsoft intermediate language ). Note: MSIL Language invented by Microsoft company.
5.MSIL code sent to CLR (Common language runtime).
6.Just in time compiler (JIT) present in CLR converts MSIL code to machine level language (that is into Bits 0's and 1's representation ).
7.CPU/Processor present in computer executes Machine level code and produces the output again in machine level language.
8.Monitor converts machine level out put produced by CPU into human readable language(English language). Note: When the program is created in visual studio it is stored in Hard disk, but during execution program is stored and executed using RAM memory (Since RAM is an high speed elctronic device compared to Hard disk memory ).

Compilation and execution diagram: