Importance of Bin and Obj Folders in .NET

Introduction

 
In this blog, we are discussing the importance of the bin and obj folder in C# compiling.
 
Both of these folders have compiled code? Yes, both of these folders have compiled code, but the real question is, Why do we need two folders for the compilation process? Because the compilation process happens in a two-step process.
  1. Compiling 
  2. Linking 

While compiling every code file, it's compiled as an individual compile unit. For example, if we have two files in our project, file1 and file 2 these two files will be compiled individually. Please check the below snapshot.
 
 
 
The second process is when individually compiled code unit is linked to a single unit that can be assembled as .exe or dll. 
The first reason why we have obj and bin folder is in the obj folder individual compiled file will be there and in bin folder single unit file will be there.
 
Now assume that we have multiple files in our project. Let's say after compilation if you make some changes on a particular file, then the only particular file should have been properly compiled. The C# compiler only compiles modified files instead of all files with help of tracking the obj folder. Please check the below snapshot. 
 
 
 
 

Summary

 
In this blog, we have discussed obj and bin folder usage while compiling the project.