Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: Random numbers PinPopular
David19876-May-11 2:56
David19876-May-11 2:56 
AnswerRe: Random numbers Pin
Luc Pattyn6-May-11 3:06
sitebuilderLuc Pattyn6-May-11 3:06 
GeneralRe: Random numbers PinPopular
David19876-May-11 3:45
David19876-May-11 3:45 
AnswerRe: Random numbers Pin
Luc Pattyn6-May-11 3:52
sitebuilderLuc Pattyn6-May-11 3:52 
GeneralRe: Random numbers PinPopular
David19876-May-11 3:57
David19876-May-11 3:57 
GeneralRe: Random numbers Pin
PIEBALDconsult6-May-11 16:19
mvePIEBALDconsult6-May-11 16:19 
GeneralRe: Random numbers Pin
David19876-May-11 21:41
David19876-May-11 21:41 
AnswerRe: Random numbers Pin
Orcun Iyigun6-May-11 8:37
Orcun Iyigun6-May-11 8:37 
int maxSize = 10;                
char[] chars = new char[62];
string a;
a = "1234567890";
chars = a.ToCharArray();
int size = maxSize;
byte[] data = new byte[1];
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
size = maxSize;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder resultUID = new StringBuilder(size);
foreach (byte b in data)
{
   resultUID.Append(chars[b % (chars.Length - 1)]);
}
string generatedNumber = resultUID.ToString(); 


This will generate a number. It will never return the same number. You can specify the length of it by changing the maxSize. You can add letters by just updating string variable "a" if you want.
AnswerRe: Random numbers Pin
Prasanta_Prince6-May-11 15:32
Prasanta_Prince6-May-11 15:32 
GeneralRe: Random numbers Pin
meet_ssr6-May-11 22:30
meet_ssr6-May-11 22:30 
AnswerRe: Random numbers Pin
lampiclobe7-May-11 0:49
lampiclobe7-May-11 0:49 
GeneralRe: Random numbers Pin
meet_ssr8-May-11 20:54
meet_ssr8-May-11 20:54 
AnswerRe: Random numbers Pin
lampiclobe10-May-11 11:56
lampiclobe10-May-11 11:56 
AnswerRe: Random numbers Pin
#realJSOP7-May-11 1:33
mve#realJSOP7-May-11 1:33 
RantRe: Random numbers Pin
lampiclobe7-May-11 12:26
lampiclobe7-May-11 12:26 
GeneralRe: Random numbers Pin
#realJSOP7-May-11 12:47
mve#realJSOP7-May-11 12:47 
GeneralRe: Random numbers Pin
lampiclobe7-May-11 20:45
lampiclobe7-May-11 20:45 
Questionadd and not add button "show data" in to Datagrid in C# ???? Pin
aa_zz6-May-11 0:19
aa_zz6-May-11 0:19 
AnswerRe: add and not add button "show data" in to Datagrid in C# ???? Pin
Ravi Sant6-May-11 1:17
Ravi Sant6-May-11 1:17 
QuestionHow to resolve the XML Error Pin
meeram3955-May-11 22:40
meeram3955-May-11 22:40 
AnswerRe: How to resolve the XML Error Pin
Pete O'Hanlon5-May-11 23:09
mvePete O'Hanlon5-May-11 23:09 
GeneralRe: How to resolve the XML Error Pin
meeram3955-May-11 23:18
meeram3955-May-11 23:18 
GeneralRe: How to resolve the XML Error Pin
Pete O'Hanlon6-May-11 0:13
mvePete O'Hanlon6-May-11 0:13 
AnswerRe: How to resolve the XML Error Pin
Eddy Vluggen6-May-11 0:04
professionalEddy Vluggen6-May-11 0:04 
GeneralRe: How to resolve the XML Error Pin
meeram3956-May-11 0:14
meeram3956-May-11 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.