Value types (and consequently, structs) existed in .NET since its inception, yet they are still a source of confusion in 2023 (at least for me). So I decided to collect a list of subjects, that may or may not be so obvious to some .NET developers, and I'll discuss them in the following posts (I'll update the list adding links as I post about each topic):
- This post.
- Brief introduction to Value Types vs Reference Types.
- Field initialization in structs.
- Constructors and struct behavior.
- Other scenarios in which struct constructors behavior may surprise you.
- Struct with default argument values in constructors, a.k.a, are you not confused yet ?
- `required` feature from C# 11 will not save your
a**job. - Struct used as default argument values.
- Bonus: Struct evolution in C#.
Before continuing, note that this series reflects the current state of C# as of version 11 (.NET 7.0).
Last, but not least, even if you are an experienced C# developer I hope you can learn something or, why not, add your own perspective/contribution to the subject.
As always, all feedback is welcome.
Have fun!
No comments:
Post a Comment