How to customize strings with Format method?
-
Hello, I'm not sure about how to customize formats in strings. I.e, I want a string that is an integer number, but with some zeros at the beginning to have a certain length. So, if I have an integer value: i = 1, I want to convert it to string so it gets: "000001", with length 6. I'm trying with i.ToString(), trying to guess which format to put to achieve that. Do you know the solution?
Regards, Diego F.
-
Hello, I'm not sure about how to customize formats in strings. I.e, I want a string that is an integer number, but with some zeros at the beginning to have a certain length. So, if I have an integer value: i = 1, I want to convert it to string so it gets: "000001", with length 6. I'm trying with i.ToString(), trying to guess which format to put to achieve that. Do you know the solution?
Regards, Diego F.
-
Hello, I'm not sure about how to customize formats in strings. I.e, I want a string that is an integer number, but with some zeros at the beginning to have a certain length. So, if I have an integer value: i = 1, I want to convert it to string so it gets: "000001", with length 6. I'm trying with i.ToString(), trying to guess which format to put to achieve that. Do you know the solution?
Regards, Diego F.
ToString ( "000000" )
-
ToString ( "000000" )
or ToString("D6"); analogous to ToString("X8"); for hex
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
-
ToString ( "000000" )