I wrote this line of code to handle nulls but I still get an "Object reference not set to an instance of an object" error whenever I run this line of code when expectedItem is null. What gives? What's the proper way to write this? Since expectedItem is null, I'd expect expectedItem.ExpectedResultAmount to be null also so this statement should assign an empty string to x.
string x = expectedItem.ExpectedResultAmount != null ? expectedItem.ExpectedResultAmount : "";