I am working on C# application (.Net 4.0). At some situation I want to append the multiple ushort values as mentioned below
Ushort a = 123;
Ushort b = 045;
Ushort c = 607;
Ushort d = 008;
And I want the result as 12304560700.
Currently with below approach
var temp = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c) + Convert.ToString(d);
I am getting the temp value as 123456078.
I do understand that because of ushort datatype it eliminate all the leading zero. But I am expecting the result as 12304560700.
I may have made the use of padleft method but the length and leading zero counts are not fix, so that option also doesn’t suits my requirement.
I would like to know how I can achieve the same, any small inputs on the same is also greatly appreciated.
Thanks in advance.
You want all your numbers to be formatted using 3 digits, with leading zeros if needed. Looking at Standard Numeric Format Strings you get this: