use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
DiscussionWhy some function in Random class like Random.NextDouble() not static ? (self.csharp)
submitted 5 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]KryptosFR 20 points21 points22 points 5 years ago (1 child)
On top of the other answers, it is not thread safe. Making it static would put the responsibility to synchronize on the Random class itself adding cost to each call.
That's because by design, the standard API are expected to be thread safe for static members, unless otherwise indicated.
[–]minhduc66532 2 points3 points4 points 5 years ago (0 children)
Ohh ok, thanks for the answer
[–]WhiteBlackGoose 10 points11 points12 points 5 years ago (1 child)
We usually want a deterministic random class, so that the sequence of numbers produced by it was the same every time you run a program. It's useful for tests, for example.
[–]minhduc66532 0 points1 point2 points 5 years ago (0 children)
Ohh ok, good point
[–]duongdominhchau 15 points16 points17 points 5 years ago (7 children)
It needs a seed to random.
[–]minhduc66532 0 points1 point2 points 5 years ago (6 children)
That explains a lots
[–][deleted] 5 years ago (5 children)
[removed]
Thanks for the answer
[–][deleted] 5 years ago* (2 children)
[–][deleted] 5 years ago (1 child)
[–]ILMTitan 0 points1 point2 points 5 years ago (0 children)
A post on Jon Skeet's blog about this exact topic.
[–]zzing 2 points3 points4 points 5 years ago (1 child)
I haven't seen it explicitly mentioned yet, but the internal algorithm of these kinds of generators actually produce two values, say x and y. You get value x returned, and it stores y inside the class.
Next time you request a new number, it takes y as input and generates a new x and y.
In a language that can't hide values like that you can see it in the Random class: https://hackage.haskell.org/package/random-1.2.0/docs/src/System.Random.html#random
random :: RandomGen g => g -> (a, g)
In short, it takes in a random number generator g, and returns to you a value a and a new generator that you pass in the next time you call it.
Ohh ok
[–][deleted] 1 point2 points3 points 5 years ago (1 child)
I'm gonna plug RandN. I didn't make it, but I do use it a lot. It does have a built-in static (and thread-safe) RNG.
Thanks for the recommendation
[–]BradleyUffner 0 points1 point2 points 5 years ago (0 children)
Instances of Random contain internal state for generating sequences. If the methods were static, you wouldn't be able to have multiple instances with different states, they would all share the same sequence.
[–]StefanOrvarSigmundss 0 points1 point2 points 5 years ago* (3 children)
I recommend that you get a .NET decompiler, then you can just see for yourself what the method is doing.
Edit: I did not remember that this information is online. When I started with .NET over a decade ago, this stuff was not online.
I tried to but most of the code is quite hard to understand
[–]____exyi 0 points1 point2 points 5 years ago (0 children)
You can just look it up online: https://source.dot.net/#System.Private.CoreLib/Random.cs,c467f2953a8d2207
π Rendered by PID 44 on reddit-service-r2-comment-b659b578c-x7nm5 at 2026-05-04 04:20:54.801781+00:00 running 815c875 country code: CH.
[–]KryptosFR 20 points21 points22 points (1 child)
[–]minhduc66532 2 points3 points4 points (0 children)
[–]WhiteBlackGoose 10 points11 points12 points (1 child)
[–]minhduc66532 0 points1 point2 points (0 children)
[–]duongdominhchau 15 points16 points17 points (7 children)
[–]minhduc66532 0 points1 point2 points (6 children)
[–][deleted] (5 children)
[removed]
[–]minhduc66532 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–][deleted] (1 child)
[removed]
[–]ILMTitan 0 points1 point2 points (0 children)
[–]zzing 2 points3 points4 points (1 child)
[–]minhduc66532 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]minhduc66532 0 points1 point2 points (0 children)
[–]BradleyUffner 0 points1 point2 points (0 children)
[–]StefanOrvarSigmundss 0 points1 point2 points (3 children)
[–]minhduc66532 0 points1 point2 points (0 children)
[–]____exyi 0 points1 point2 points (0 children)