How cast in c#/.net 3.5 works? for types with '?'
- by Inez
This is my code which works
public decimal? Get()
{
var res = ...
return res.Count() > 0 ? res.First() : (decimal?) null;
}
and this one doesn't work
public decimal? Get()
{
var res = ...
return res.Count() > 0 ? res.First() : null;
}
giving the compilator error: Error 1 Type of conditional expression cannot be determined because there is no implicit conversion between 'decimal' and ''
I wonder why? any ideas?