Which is better return null or empty object?
var entity = GetFromDB();
if (entity != null)
{
var price = entity.Price != null
? PriceDecorator.Decorate(entity.Price)
: null;
}
public class PriceDecorator
{
public static string Decorate(decimal? price)
{
if (price == null || price == 0)
return String.Empty;
return String.Format(CultureInfo.CurrentCulture , "{0:C}", price);
}
}
In the above code, sometimes I return null and sometimes I return Sting.Empty, I don't know what to return to indicate 'no data'.
Any advice?
Thanks in advance