Viewing a single comment thread. View all comments

oneeyedziggy t1_ixilahp wrote

Awesome context... As I'm not a c# dev (well, my professional use of c# was extremely short lived and 10+ years ago...)... I was thinking in terms of what little java I know (also not a java dev) but how basically all options 9n a variable are enumerated in long-form when declaring ( public static String blah blah...) and just imagining (naively, based on the previous comment) that it might have been as simple as adding a byref or byval to the string of qualifiers when using a class to get struct behavior (and defaulting to some sane default where omitted)... Is this even relevant to the situation either in c# having such qualifiers or in classes and structs being sufficiently similar for that to be feasible (if only everything had been different)?

1

Triabolical_ t1_ixjwabm wrote

> Is this even relevant to the situation either in c# having such qualifiers or in classes and structs being sufficiently similar for that to be feasible (if only everything had been different)?

C++ is pretty much that way; structs and classes are mostly the same thing and the developer chooses whether they want to allocate it on the stack or whether they want to put it in dynamic memory.

In C# - and managed languages in general - class instances are always allocated in dynamic memory. Structs were really just added for windows interop, though they do have other limited uses.

2