Sep 27, 2019 08:05 AM|Yang Shen|LINK
Thank you so much, to be frank, i was not familiar with MVC html helper with Lambda expression.
But after several hours learning about this and also with the help of your code, i finally understand how this thing goes.
As for your question:
I need to convert below line of code:
property == null ? string.Empty : property.ToString()
to use Equals to compare. Can it be done?
The answer is NO, you can't use object.equals() method to a null object.
For the method, it needs to work like xxx.Equals(null) instead of null.Equals(null).
When the propert is null, it will generate an error: Object reference not set to an instance of an object.
Lastly, if the property can be null in cases, you should use the property == null ? string.Empty : property.ToString().