Mafullah Backtrack Mafullah Backtrack - 8 months ago 16
SQL Question

Calculation without losing the digit number

I want to add between two of numbers from right. Number of one is "000220", the second is "1". After I was add of them, the result is "221".

How to add/increase that two both number without losing the zero or digit, like this :

______ +

I want to using for increment for sql from behind Code.


You could use string.PadLeft to add leading zeros after adding two integers.

    string one = "000220";
    string two = "1";

    (int.Parse(one) +int.Parse(two)).ToString().PadLeft(6,'0')

Working example