public InstanceNullCheck() { SampleData sData = new SampleData(); if (sData.MyName == String.Empty) { sData = null; } WriteLine(sData?.MyName ?? "Field is null."); ReadLine(); }
public NullConditionalOperator() { SampleData sData = new SampleData(); if (sData.MyName == String.Empty) { sData = null; } WriteLine(sData != null ? sData.MyName : "Field is null."); ReadLine(); }