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 244 views
1 answer 266 views
1 answer 189 views
2 answers 323 views
323 views asked Dec 23, 2016 by avibootz
1 answer 250 views
1 answer 172 views
...