kensy11
asked on
how to generator random numbers
hello,
i want to generat random numbers in c# how can i do it ?
the random numbers should at MIN be 1 digit long and MAX 9 digits long
Thank you
i want to generat random numbers in c# how can i do it ?
the random numbers should at MIN be 1 digit long and MAX 9 digits long
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not sure about that format specifier, but you can use "{0:000000000}" and it should give you that output.
P.S.
StudentNum will need to be a numeric type (e.g. int, decimal, double, etc.) in order for the padding to work the way you are expecting.
StudentNum will need to be a numeric type (e.g. int, decimal, double, etc.) in order for the padding to work the way you are expecting.
ASKER
thank you very much
ASKER
i like the outcome of this line of code to be like this
000000045 for example not just 45 so i used {0:d9} but its not working do you know why ?
Console.WriteLine("Het nummer {0:d9} is een geldig studentnummer.", StudentNum");