• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Help me out here :)

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
I have been presented with this method and asked to give it a name. I've stared at it for an hour or so, and damn it I should know what this is.... but my brain isn't working.

int Foo(int a, int b)
{
return ( new Random().Next() % (b - a + 1)) + a;
}

I figured someone here will bail me out 🙂.
 
Are you looking for what it does, or a name for the function? I know what it does, but I'm not sure a specific name comes to mind. It gives a random integer between a and b (inclusive). Maybe RandomIntegerInRange?
 
/slaps forehead

Of course it does 🙂.

Nah, I can come up with the name myself. The problem was that I stared at it too long last night. Guess I didn't think anyone would do that rather than:

Random.Next(a, b);

See, this is what happens when you get intellectually lazy and used to using the api for everything.

Thanks!
 
Back
Top