Click here to Skip to main content
16,004,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: Stored procedure in C# Pin
mrkeivan23-Feb-08 9:25
mrkeivan23-Feb-08 9:25 
GeneralRe: Stored procedure in C# Pin
PIEBALDconsult23-Feb-08 14:56
mvePIEBALDconsult23-Feb-08 14:56 
GeneralRe: Stored procedure in C# Pin
ali_reza_zareian22-Feb-08 22:40
ali_reza_zareian22-Feb-08 22:40 
QuestionHow to generate random number [modified] Pin
D i x y22-Feb-08 20:50
D i x y22-Feb-08 20:50 
GeneralRe: How to generate base64 random number Pin
Hesham Amin22-Feb-08 22:36
Hesham Amin22-Feb-08 22:36 
GeneralRe: How to generate base64 random number Pin
D i x y22-Feb-08 22:45
D i x y22-Feb-08 22:45 
GeneralRe: How to generate base64 random number Pin
Gareth H23-Feb-08 0:08
Gareth H23-Feb-08 0:08 
GeneralRe: How to generate base64 random number Pin
Christoph Menge23-Feb-08 0:17
Christoph Menge23-Feb-08 0:17 
Hi,

what exactly are you trying to accomplish? Do you need a specific distribution, or a constant length, for example?

If you just need some keys that do not collide, i.e. keys which are (almost) unique, you might want to take a look at UUIDs or GUIDs. They are time-based, but in a more subtle manner. Their length is constant. However, they are usually written in hexadecimal strings, e.g.: {2AED1BB2-7314-43e9-9DE7-8AAB3BBC20C1}.

Or do you just need something like

Random a = new Random();<br />
string x = String.Format("{0}{1}", a.Next(), DateTime.UtcNow.Ticks);


?

yielding, for example, this:
"2143552667633393651580403445"


Note that this has a variable length, because
a.Next()
returns some number which can be shorter or longer.

Also note that a, if initialized without a seed will use the system time as seed, thus creating completely different numbers on each run (these alone, however, have a rather large chance of colliding).


In general, there are no keys which can *never* collide (unless they have infinite legth...), but you can make it extremely unlikely to happen.


Hope that helps,


Chris

"Obstacles are those frightening things you see when you take your Eyes off your aim"
- Henry Ford

Articles 
Blog

GeneralRe: How to generate base64 random number Pin
Guffa23-Feb-08 0:25
Guffa23-Feb-08 0:25 
GeneralRe: How to generate base64 random number Pin
D i x y23-Feb-08 0:53
D i x y23-Feb-08 0:53 
GeneralRe: How to generate base64 random number Pin
Hesham Amin23-Feb-08 5:24
Hesham Amin23-Feb-08 5:24 
GeneralC# windows service is not showing in Control panel services Pin
Satish - Developer22-Feb-08 20:12
Satish - Developer22-Feb-08 20:12 
AnswerRe: C# windows service is not showing in Control panel services Pin
Mohammed Shahab23-Feb-08 1:36
Mohammed Shahab23-Feb-08 1:36 
QuestionHow to get clear figure in windows application? Pin
Aravinthan22-Feb-08 19:25
Aravinthan22-Feb-08 19:25 
AnswerRe: How to get clear figure in windows application? Pin
Christian Graus22-Feb-08 19:41
protectorChristian Graus22-Feb-08 19:41 
GeneralRe: How to get clear figure in windows application? Pin
Aravinthan22-Feb-08 21:59
Aravinthan22-Feb-08 21:59 
NewsVTD-XML 2.3 Pin
Jimmy Zhang22-Feb-08 19:00
Jimmy Zhang22-Feb-08 19:00 
GeneralRe: VTD-XML 2.3 Pin
Christian Graus22-Feb-08 19:05
protectorChristian Graus22-Feb-08 19:05 
GeneralRe: VTD-XML 2.3 Pin
Jimmy Zhang22-Feb-08 19:16
Jimmy Zhang22-Feb-08 19:16 
GeneralFailed to load provider type Pin
paulb22-Feb-08 18:27
paulb22-Feb-08 18:27 
GeneralRe: Failed to load provider type Pin
Hesham Amin22-Feb-08 22:40
Hesham Amin22-Feb-08 22:40 
GeneralRe: Failed to load provider type Pin
paulb23-Feb-08 0:36
paulb23-Feb-08 0:36 
GeneralOpenVPN bandwidth controlling Pin
vikramspce198322-Feb-08 17:38
vikramspce198322-Feb-08 17:38 
GeneralAccessing Thunderbird data using C# Pin
Umer Sheikh22-Feb-08 16:20
Umer Sheikh22-Feb-08 16:20 
GeneralRe: Accessing Thunderbird data using C# Pin
N a v a n e e t h22-Feb-08 17:44
N a v a n e e t h22-Feb-08 17:44 

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.