What's the difference between struct and class in C#?
Structs are passed by value, not by reference.
Assign it to the object, pass an object.
Why do you need to box a primitive variable?
To pass it by reference.
Stack to heap Boxing
Heap to Stack UnBoxing
• When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.
• It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.
• It is an error to initialize an instance field in a struct.
• There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.
• A struct is a value type, while a class is a reference type.