3 ms·
The automated property generators are just syntactic sugar. At the moment, if I want a property that's settable inside and out I can can type: public string
by AndrewDucker 16y ago
The automated property generators are just syntactic sugar. At the moment, if I want a property that's settable inside and out I can can type:
public string MyString{set;get;}
In order to do the same with an immutable property requires a fair bit more code.
private readonly string myString;
public string MyString
{
get
{
return myString;
}
}
Replacing all of that with
public readonly string MyString{get;set;}
would be handy, and work with the way the language currently does.
- deleted 16y ago[deleted]
- AndrewDucker 16y agoOh, absolutely. It's not vital - it's just that with there being more multithreaded stuff going on I'd like easier ways of making it clear what's immutable and what isn't. Heck, I'd love a way of saying "immutable class" in the same way you can with a "static class", just to ensure I haven't missed anything!
- adambyrtek 16y agoI deleted my previous comment shortly after posting because I realized that you're right, this would be definitely useful. I haven't noticed that you already managed to reply to it.