_item = new OutTYonetimOzet();
_item.Banka = Convert.ToDecimal(" ");
liste.Add(_item);
There is a list called liste. In List item Banka named element is decimal value. I want to show the empty string when I show it on the screen. But this code is getting an error that can not be cast. What is the problem.
Error message is:
Input string was not in a correct format.
There's no such thing as a "blank decimal". decimal cannot have a value that is "blank" - it always has a numeric value. Convert.ToDecimal(" ") is nonsensical - there is nothing it can return that makes sense.
You could try using a Nullable<decimal> (aka decimal?) perhaps; i.e.
public decimal? Banka {get;set;}
and
_item.Banka = null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With