format problem
C#
3
Posts
2
Posters
0
Views
1
Watching
-
Hi, i have one number and i want to transform in one string but with one fixed format: EX: if i have int x=10; int y=999; my string must be string sForX="0010"; string sForY="0999"; (i want to do that without to format the string manual (with for, while or.....) )
-
Hi, i have one number and i want to transform in one string but with one fixed format: EX: if i have int x=10; int y=999; my string must be string sForX="0010"; string sForY="0999"; (i want to do that without to format the string manual (with for, while or.....) )
-
You can use String.Format:
int x=10;
int y=999;string sForX=String.Format("{0:0000}", x);
string sForY=String.Format("{0:0000}", y);