Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generate same password in the same second
Message
From
10/11/2008 09:36:58
 
 
To
10/11/2008 03:59:08
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01360833
Message ID:
01360885
Views:
5
>>>>>try
>>>>>
>>>>>dim loRnd = new Random( DateTime.Now.Ticks.GetHashCode() );
>>>>>
>>>>
>>>>It is the same thing.
>>>
>>>sorry Michel, but
>>>
>>>var xx = new Random(DateTime.Now.Ticks.GetHashCode());
>>>
works perfectly here
>>>
>>>The Random constructor takes an int32 and .GetHashCode() returns an int32
>>>
>>>I don't understand it
>>>
>>>btw, what about making loRnd a static field ?
>>
>>Hi,
>>
>>See my post to Michel - VB only does checked cast.
>>But I agree using a static would be better....
>__
>Viv,
>
>I'm not into vb - hence - I don't know how to cast in vb
>
>What I don't understand is that long.GetHashCode() returns an int32 and that Michel is still having a problem with that
>Do you understand ?

Huh.... no.
I looked at .Ticks (which is a Long). For that CInt() would throw an error if the value was > Int32.MaxValue (same as using a C# cast with checked())

But, since, as you say, GetHashCode() returns an Int I don't see how it could generate an error (I'm assuming that Michel meant that it *was* that specific line that caused the exception.....)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform