The
GetTickCount()
call is used to get a random start value stored in a static variable (it is only called once at program start). The casting to
short
will limit the value to 16 bits (ignore the higher bits).
You can create a static class and also use the C# Random class for similar behaviour :
public class MyClass
{
static int i;
static MyClass()
{
i = Environment.TickCount() & 0xffff;
}
void DoIt()
{
if( ~i & 2 )
{
i+=3U;
}
else
{
i+=5U;
}
}
};