Genetrate Random Integer


Extended C# function to genetrate random integer.

Code Snippet

public static Int32 NextInt32(this Random rnd)
    var buffer = new byte[sizeof(Int32)];
    return BitConverter.ToInt32(buffer, 0);

Sample Usage

Random rnd = new Random();
int intRnd = rnd.NextInt32();

author's photo

Author : Si Thu

I am just a normal programmer. Cool, quiet and simple person. Love to write code without pressure. Most of the time, I am reading, writing, watching movie or surfing the web.

blog comments powered by Disqus