doramail05
asked on
length 10 in an integer in C#
hi there, how do i actually declare or make an integer 10 in size .eg. 0000000001. ? in c#
what do u want to do with 0000000001 ?
You can't exactly do that. As you have probably seen if you supply an integer the value 00001 it will be 1 because that is numerically what you are giving it. An integer will not hold places as a data type it will store the value you supply it.
Now for display purposes you can cause an integer to display on the screen that way using string custom formatting like this (sorry close as I can get'cha).
EX.
Dim i As Integer = 10
Dim j As String = i.ToString("000000000")
Response.Write(j)
'Produces 000000010 if i=1
'Produces 000000010 if i=10
Now for display purposes you can cause an integer to display on the screen that way using string custom formatting like this (sorry close as I can get'cha).
EX.
Dim i As Integer = 10
Dim j As String = i.ToString("000000000")
Response.Write(j)
'Produces 000000010 if i=1
'Produces 000000010 if i=10
Sorry I wrote that last bit wrong:
'Produces 000000001 if i=1
'Produces 000000010 if i=10
'...etc
'Produces 000000001 if i=1
'Produces 000000010 if i=10
'...etc
int num;
num = 1;
Response.Write(string.Form at("{0:000 0000000}", num));
try this
when you give input 1 it will add 9 0's before it
if you giove 12 it will add 8 0's before it
num = 1;
Response.Write(string.Form
try this
when you give input 1 it will add 9 0's before it
if you giove 12 it will add 8 0's before it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
LOL lots of same thing....must be on the right track :)
I can't even imagine how you chose to award the points here, but alas...win some/lose some I suppose.