First of all, I don't think
System.Random
gives predictable results. If you say so, would you please demonstrate your prediction? However, I'm not sure if the result of random generation is not correlated and obey required distribution. Even if it not perfect, it does not mean predictability.
Now, let's assume you have random byte. Let's say your method is
byte Random()
.
int RandomInt() {
byte numBytes = sizeof(int);
int value = 0;
for (int index = 0; index < numBytes; index ++)
value |= Random() << index * 8;
return value;
}
Same thing with any other integer type. All you need is to shift each byte by the number of bits need to put it in all byte positions in sequence and OR with previous result. As number of bytes is calculated from the target type, it will work no matter what type you want to use as a target but... to write a generic (in a simple way) is nearly impossible.
—SA