Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random string generation
Message
De
20/10/2010 08:27:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/10/2010 07:59:30
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
Application:
Web
Divers
Thread ID:
01486288
Message ID:
01486292
Vues:
38
>Hi all,
>
>I need to generate a random string with a set length to use for creating a login account and and linking it to an exisiting customer account. Since I need to be able to differentiate it from another random generated string it would be nice if I could generate numerous strings from the same base value or something.
>
>What is the best way to do this? I am thinking somewhere between 10 and 15 characters is sufficient for this.
>Thanks
>Tim
List<Guid> names = new List<Guid>();
byte[] r = new byte[8];
for (int i = 0; i < 100; i++)
{
    RandomNumberGenerator.Create().GetBytes( r );
    names.Add( new Guid(1,2,3,r) );
}
var accounts = names.Select (n => n.ToString("N"));
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform