I have the following code to get values from the list.
GetList().SingleOrDefault(x => x.Key == "MyKey").MyValue;
When there is Key property with value MyKey in a list it is working fine but when there is not Key property with value MyKey in a list it is throwing an NullReferenceException. How can I return null value instead of exception.
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.