because in order to write more robust, efficient, and maintainable code, we have to know how classes, objects, and memory management work in the C# programming language. By understanding concepts like constructors, properties, and memory allocation on the stack and heap, developers can write more efficient and reliable code.
a static constructor is called once per class before any static members are accessed, while an instance constructor is called each time an instance of a class is created.
Setting properties/values can be done at any time during an object’s lifetime
static constructor called only once before any static member is accessed.
avoiding unnecessary object creations. , Minimizing the use of large objects on the stack and allocating them on the heap instead.
garbage collection is automatic whereas household is manual but both of them frees space occupied by things no longer in use. ______
Memory management in .NET and how garbage collector works .