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 163 views
1 answer 175 views
1 answer 95 views
2 answers 210 views
210 views asked Dec 23, 2016 by avibootz
1 answer 168 views
1 answer 82 views
...