How to format int as string in C#

1 Answer

0 votes
using System;

class Test
{
    static void Main() {
        int n = 746;
        
        string str = n.ToString("0000");

        Console.WriteLine(str);
    }
}



 
/*
run:

0746
 
*/

 



answered Oct 30, 2022 by avibootz

Related questions

1 answer 150 views
1 answer 167 views
1 answer 84 views
2 answers 201 views
201 views asked Dec 23, 2016 by avibootz
1 answer 158 views
1 answer 75 views
...