General
CLR and Compilation in C#
In C#, the Common Language Runtime (CLR) serves as the compiler. When writing C# code, the compilation process involves translating the code into an intermediate language (IL) that the CLR can understand. This IL code is then compiled into machine code at runtime by the CLR.
To compile C# code using the command-line compiler, you can use the csc command followed by the filenames. For example:
csc *.cs *.exe
If you want to compile your code into a library (DLL), you can use the following command:
csc /target:library *.cs *.dll
Immutable Objects
In programming, “immutable” objects are those whose state cannot be changed after they are created. In C#, using immutable objects can lead to more predictable code behavior and help in avoiding bugs related to unintended modifications.
Value Types and Unification in C#
Value types in C#, such as int, represent data directly and are stored on the stack. These types have a fixed size and are copied by value when passed around.
C# allows for unification, which is the process of converting value types to objects (reference types) through a mechanism called boxing. This enables value types to be treated as objects in certain contexts.
