C# – краткая форма проверки и присвоения значения null в одной строке ⇐ C#
-
Anonymous
C# – краткая форма проверки и присвоения значения null в одной строке
I'm wondering if there's a shorter way to write something like this:
var element = Data.GetElement(); if (element != null) element.IsSelected = true; In a way like this or similar in one line of code:
Data.GetElement()?.IsSelected = true;
Источник: https://stackoverflow.com/questions/781 ... n-one-line
I'm wondering if there's a shorter way to write something like this:
var element = Data.GetElement(); if (element != null) element.IsSelected = true; In a way like this or similar in one line of code:
Data.GetElement()?.IsSelected = true;
Источник: https://stackoverflow.com/questions/781 ... n-one-line
Мобильная версия