更新时间:2023-02-14 20:34:09
使用decimal.TryParse
和Nullable Decimal
喜欢...decimal tmpvalue;
十进制? result = decimal .TryParse(( string )dtrow [ LPvsMAXFMV], out tmpvalue)?
tmpvalue:( decimal ?) null ;
查看此链接
null和System.DBNull.Value有什么区别? [ ^ ]
In Database
LPvsMAXFMV numeric(18,0)
LPvsMAXFMV is NULL
ASP.NET
decimal demo=0(Zero);
decimal LPvsMAXFMV =Convert.ToDecimal(dtrow["LPvsMAXFMV"])!=null? Convert.ToDecimal(dtrow["LPvsMAXFMV"]):demo;
This is not working, How to correct this
Usedecimal.TryParse
andNullable Decimal
like...decimal tmpvalue; decimal? result = decimal.TryParse((string)dtrow["LPvsMAXFMV"], out tmpvalue) ? tmpvalue : (decimal?)null;
Check this link
What is the difference between null and System.DBNull.Value?[^]