Non-Repetative Random Numbers as per Requirement.
In this article i will show you how can you get non-repetitive and fixed no of digit's random numbers as per your no of digit.there is lot's of methods are used for that.there is simple logic behind that. you can fix no of digit as per your requirement using this code.
We all know that many time we have requirement for get random numbers.there is lot's of method for create random number.you can find it from google.
one of the most common method is here i give you,
Random rnd = new Random();
int s = rnd.Next(000000, 999999);
Password=s.tostring();
with using this code you can generate random number,but it will be repetitive.and if you want only 6 digit's random number then you can't get it from this code.
for get non repetitive and fixed no of digit's random code you have to use this method for that.
var char = "0123456789";
var random = new Random();
var result = new string(Enumerable.Repeat(char, i).Select(s => s[random.Next(s.Length)]).ToArray());
PAssword=result.tostring();
so,as per your requirement you can get non repetitive and fixed digit's random number with using this code,
if you want 5 digit's fixed random number then simply take i's value 5
so change i's value as per your requirement.
if you take i's value 5 then you get this results
00000
12345
12435
65764
34353
45465
etc.
I hope this will help you.
Thanks&Regards,
Ketan Italiya