Archives

Archives / 2017 / October
  • Struct vs. class

    Structs seem to be largely ignored in .NET. Everyone uses them (Int32 is pretty common!), but rarely pay attention to the fact that they're structs instead of classes, and rarely need to. I've worked on several projects where I don't think a single custom struct was defined. A good .NET/C# programmer should understand the differences between classes and structs as they consume them, but when creating a new type, most folks just create a class without a second thought (a class is usually the right answer anyway).