c# - in random number generator -



c# - in random number generator -

for reason, code works fine when don't utilize seed in random class, if seek utilize datetime.now more random number, stackoverflowexception! class simple. tell me i'm doing wrong here? see makeuniquefilename.

public class temputil { private int strcmp(string s1, string s2) { seek { (int = 0; < s1.length; i++) if (s1[i] != s2[i]) homecoming 0; homecoming 1; } grab (indexoutofrangeexception) { homecoming 0; } } private int uniqueness(object randomobj) { switch (randomobj.tostring()) { case "system.object": case "system.string": homecoming randomobj.tostring()[0]; case "system.int32": homecoming int.parse(randomobj.tostring()); case "system.boolean": homecoming strcmp(randomobj.tostring(), "true"); default: homecoming uniqueness(randomobj.tostring()); } } public string makeuniquefilename() { homecoming "c:\\windows\\temp\\" + new random(uniqueness(datetime.now)).nextdouble() + ".tmp"; } }

in short:

it should

switch (randomobj.gettype().tostring())

instead of

switch (randomobj.tostring())

but isn't clever.

c# random stack-overflow

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - cuda, pycuda -- how to write complex numbers -- errors:class "cuComplex" has no member "i" -

How do I check if an insert was successful with MySQLdb in Python? -