|
| How To create a unique number everytime |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.languages.csharp.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Bill |
I need to create a temporary file on the file system. I have over 5000 users.
What's the best method to ensure uniqueness?
Thanks
Bill
|
|
|
| |
|
| |
| | |
| |
| gabriel |
[Original message clipped]
Depends on the application. You might get away with just starting at #1. You might get away with having an array of booleans (or a table of booleans in a database), one starting at #1 and so on. Or you might have to generate a random number and keep retrying till you hi one that's not in use.
It all depends on how often you need to do this, what the load is (are your 5k users concurrent?), and so on.
This can be very fast if you plan it right. If you go the random number route, use a hige range (ie, a number between 1 and 1,000,000) so that conflicts are very unlikely.
-- gabriel
|
|
|
| |
|
|
| |
| | |
| | |
| |
| Doug Erickson [MS] (VIP) |
Guid.NewGuid() will produce a random GUID. A GUID is a large, unique hex-based value suitable for database and registry keys.
For example:
Guid myKey = Guid.NewGuid(); Console.WriteLine("New Key: {0}", myKey.ToString());
Hope this helps!
-- ---- Doug Erickson [MSFT], Platform SDK UA This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. 2003 Microsoft Corporation. All rights reserved.
"gabriel" <Click here to reveal e-mail address> wrote in message news:b86e7$402ab8f1$437be569$Click here to reveal e-mail address... [Original message clipped]
|
|
|
| |
|
|
| |
|
|
| | |
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|