Richard Deeming wrote:
That would give you a CS0106 compiler error. :)
Not on a struct. :rose: Some C# features are intended mostly or solely to try to help produce more readable code. But some (like the readonly
modifier on struct
s and their members) exist because they allow increased performance and/or compiler-enforced constraints against unintended usages of objects and their members. All that said, I have definitely seen (fine, I'll admit it, sometimes even written :~) code that goes overboard with the more concision-focused syntax that OP mentions. Doesn't help that VS is constantly underlining anything that can be converted to a ternary or expression-bodied member. X| Don't get me wrong, these two things have their place, and the corresponding auto-fixes should be right there in the editor context menu, but their possibility shouldn't trigger the code underlining... :java: