Link to home
Start Free TrialLog in
Avatar of kensy11
kensy11Flag for Belgium

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
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kensy11

ASKER

thank i have one other small qaustion could you please help me

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");
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.
Avatar of kensy11

ASKER

thank you very much