A null value should be considered as 0 when addition of it is done with decimal value.

Posted by Harikrishna on Stack Overflow See other posts from Stack Overflow or by Harikrishna
Published on 2010-05-15T05:18:33Z Indexed on 2010/05/15 5:24 UTC
Read the original article Hit count: 237

Filed under:
|
|

There are three column in the datatable A,B and C. Now each column is type of decimal. Now I am doing like dt.Columns["A"].Expression="B+C"; to make addition of Column B's record and column C's record. Now if there is any value of B or C is null then addition of B and C will be null like B's value is 3 and C's value is null for first row then B+C(3+null) will be null which is not appropriate, the result of addition should be 3.If I replace 0 instead of null then it will be ok.But whereever there is null value in the records it should be remain it is and it should not be replaced by 0.That is null value should not be replaced by 0 and when addition of null value is done with any decimal value null value should be considered as 0.

Is it possible,how can we do this ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms