int num = 00;
string s=num.ToString();
It is giving value "0". The expected result is "00". How to do this?
Can anyone Help me?
int num = 00;
string s=num.ToString();
It is giving value "0". The expected result is "00". How to do this?
Can anyone Help me?
It's in your value assignment. An int
of 00 always has value 0. If you want to always show two digits, you need to apply a format to your ToString()
call
int num = 00;
string s= num.ToString("D2");
That should do the trick.
You can achieve the desired result using the implementation of the ToString() method passing a parameter "D2" as shown in the demo link: http://rextester.com/JKIDK14711 Or you can get more information about the parameters that ToString() accepts from here: https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx