Just to reiterate – What are the value types (structs, enums)
Value types are cut-down classes. Imagine classes that don’t support inheritance or finalizers, and you have the cut-down version: the struct. Structs are defined in the same way as classes (except with the struct keyword), and apart from the some limitations (described below) , structs can have the same rich members, including fields, methods, properties and operators.
In the previous post I have also outlined several benefits of using value types:
1) They don’t require garbage collection
2) They use less space due to alignment and having no object header
3) Even though they are copied you can still get around the issue by using the ref keyword
4) By default value types are not nulluble, but you can wrap them into Nulluble, essentially achieving the same semantics as a reference type.
However there are certain major drawbacks using value types:
Continue reading “Value Types – When (not) to Use”