2 ms·
Java's value types will be immutable, while in C# I believe structs are mutable. This is a very important difference with serious implications to concurrency.
by pron 12y ago
Java's value types will be immutable, while in C# I believe structs are mutable. This is a very important difference with serious implications to concurrency.
> Something I really miss in C#/Java is a possibility to opt out of GC and use more stack allocation.
The tradeoffs are often not what you think they are.
- alkonaut 12y agoMutable structs in c# are rare, rarely useful and often dangerous, but in some perf critical scenarios that hack is needed. Most notably the standard List<T>.Enumerator is a mutable struct because othrrwise an object would have to be created on the heap for the sole purpose of iterating a list. Not sure whether this was actually one of the reasons for allowing mutable structs to begin with, the use case is critical enough that it might well have been.