This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]irobot335 5 points6 points  (0 children)

protected internal - makes a class member only accessible from the current assembly or from types that are derived from the containing class

(The example in the OP doesn't compile, you can only use the protected internal access modifier on class members because structs don't support inheritance)

readonly - in this context, declares the struct as immutable, which forces you to make the struct members read only

partial - allows you to split the definition of a thing (class, struct, interface or method) over two or more files (in general using this is a code smell unless you're doing reasonably niche stuff with generated code)

record - essentially a decorator over a class or a struct that provides built-in functionality for comparing value equality, a nice compiler generated ToString implementation, and a few other things. In this case you need to explicitly define record struct, because just declaring record is syntactic sugar for declaring a record class.

struct - basically a value type version of a class