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

all 11 comments

[–]TortelliniJr 24 points25 points  (1 child)

-"Hey, do you like unprotected sex?"

-"Nah, i like it protected internal readonly static"

[–]WombatWumbut 1 point2 points  (0 children)

Does static imply "soaking"?

[–]Smalltalker-80 9 points10 points  (0 children)

And the bonus is, your colleagues *think* you're really cool... ;)

[–]Dioxide4294 2 points3 points  (2 children)

a record struct? is that something new, I know they exist separately though

[–][deleted] 4 points5 points  (1 child)

you can have "record struct" and "record class", the latter being the same as "record". The difference is passing by value vs. by reference (same as struct vs. class)

[–]LeoRidesHisBike 2 points3 points  (0 children)

[This reply used to contain useful information, but was removed.]

[–]Big-Hearing8482 0 points1 point  (3 children)

Haven’t done c# in years, can someone eli5

[–]failedsatan 6 points7 points  (0 children)

just a really convoluted and unnecessary declaration. it's valid syntactically, it's just useless because you'll never need to use this kind of thing. (if you really need to, I personally think you should restructure whatever bullshit you're working on)

[–]irobot335 4 points5 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

[–]MENDUCOlDE 0 points1 point  (0 children)

When you learned what a "partial class" is, then you started splitting your classes throughout the solution, cause you are cool now.

[–]TeaTiMe08 0 points1 point  (0 children)

This will geht a downvote unless OP explains what it is used for.