As we know,Null-Conditional Operator is something new in c# 6.0(https://msdn.microsoft.com/en-us/magazine/dn802602.aspx). And I tried to use it in WPF(.net framework 4.6.1).
Here is my code which is right:
PackageButtonClass PBC = PackageButtonList.Find(x => x.Index == index + 1);
if (PBC != null)
{
PBC.IsEnabled = false;
}
I wanna use Null-Conditional Operator to make it short,like this:
PackageButtonList.Find(x => x.Index == index + 1)?.IsEnabled = false;
However,WPF throw an error which is 'Left-Hand Side Of An Assignment Must Be a Variable, Property or Indexer'
What 's wrong with my code?Would you please help me?Thank you.