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 246 views
1 answer 268 views
1 answer 192 views
2 answers 330 views
330 views asked Dec 23, 2016 by avibootz
1 answer 254 views
1 answer 175 views
...