|
|
|
|
|
by batina
3500 days ago
|
|
Pattern Matching with Is Expressions Awesome! Greatly reduces "ugly" boilerplate code like this: if (control is TextBox)
{
var textBox = (TextBox)control;
textBox...
}
Also, it would be great if Microsoft could make full properties in another way so that you do not have to write a backing field for it. Something like this: public string LastName
{
get;
set
{
if (value == "Batina")
RaisePropertyChanged();
}
}
It would make code more cleaner. |
|
Normal auto-implemented properties are fine:
As are read-only ones: Yet, I feel that if you are writing logic in there then you should fully control it. Or else there is too much being done that is non-obvious and could cause problems down the line (for others or your future self).However, they might be able to achieve something with data annotations that wouldn't be too magic. For example:
Tip: In VS you can just type "prop" then press tab to auto-generate the code for a class property. You can then easily auto-change this to a fully implemented version. This also works for "for" and "foreach" loops etc.I haven't done much Java in a while but do you still have to write out all of your property accessors fully? Might not be too bad if the IDE can generate this code.