- Compile-time Process (CSC.exe)
- Run Time Process (CLR)
Compile Time Process :
- In This article, I am going to explain one c# program. first, create a program and name it "hello.cs".
- and save in any of the drivers on your computer or pc.
- Next, open the program in any one of the editors, and my suggestion uses Microsoft visual studio.
- now Compile the program
- whenever we compile the program then one ".exe " file will be generated
Run Time Process :
How the execution flow happens when you compile and execute the c# program?
- CLR means Common Language Runtime takes care of all about the execution process.
- So whenever the program compiles then the immediate step is to load the program into CLR.
- CLR search for static variables and allocate the memory for static variables
- CLR search for methods and loads into Method area as shown in the above image
- CLR searches for "static void main" and loads into the execution engine.
Simple Explanation :
- Create the c# program
- compile the c# program
- load into CLR
- execute the program
In-depth Explanation :
- Create the c# program in any local machine and save it with any name
- load the program into Visual Studio Editor
- Compile the C# program
- CSC compile will check the Syntax errors, If there are no syntax errors then it will generate the ".EXE" file.
- now onwards CLR take cares
- the program loads into CLR and the ".exe" file internally contains MSIL code.
- MSIL code did not understand by OS.
- CLR has one component that is Just In Time(JIT).
- JIT will take care of the conversion from MSIL code to Native code.
- now JIT converts the MSIL code to OS understandable language.
- finally, it generates the Output.
Simple Question to Understand.
1) Where the static variable stored in memory?
A) in Stack
2) When the memory is allocated for static variables?
A) whenever the class loads into CLR.
3) Where all the methods Loaded?
A) Method Area in RAM.
4) Where all the methods Executed?
A) Execution Engine
Post a Comment (0)