Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert integer number to three digit

I have an integer variable .if its 1-9 it only displays as "1" or "9", I'm looking to convert the variable to save as 3 digits, ie. "001", or "009", etc. any ideas? I am using C#,ASP.Net

like image 896
user1270940 Avatar asked May 31 '12 11:05

user1270940


People also ask

How many 3-digit numbers are there?

Hence, there are 900 three-digit numbers in total.

How do you print a 3-digit number in Python?

Get input num from user using input() method check whether the num is greater than 99 and less than 100 using if statement. if it is true, then print num is three digit number using print() method. Else print num is not three digit number using print() method.

How many 3-digit natural numbers can be formed using no zeros and at least one 7 in each number?

So there are 90 total.


1 Answers

use

int X = 9;

string PaddedResult = X.ToString().PadLeft (3, '0'); // results in 009

see MSDN references here and here.

like image 92
Yahia Avatar answered Oct 21 '22 02:10

Yahia