C# safe-navigation ?. operator
Instead of writing...
private StoBatch SelectedBatch
{
get { return (selectedArea != null) ? selectedArea.SelectedBatch : null; }
set { if (selectedArea != null) selectedArea.SelectedBatch = value; }
}
In C# 6 we can now write...
private StoBatch SelectedBatch
{
get => selectedArea?.SelectedBatch;
set { if (selectedArea != null) selectedArea.SelectedBatch = value; }
}
I wish they would allow me to also write...
private StoBatch SelectedBatch
{
get => selectedArea?.SelectedBatch;
set => selectedArea?.SelectedBatch = value; }
}
It would be fantastic if I could just write...
private StoBatch SelectedBatch is selectedArea?.SelectedBatch;
I keep dreaming!
Comments
Post a Comment