Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3602832
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:47:47+00:00 2026-05-18T20:47:47+00:00

I have just passed this article online: C# Corner and C# Corner and his

  • 0

I have just passed this article online:
C# Corner and C# Corner and his article (a software developer with over 13 years of experience) recommended using System.Random as follows:

private int RandomNumber(int min, int max)
{
    Random random = new Random();
    return random.Next(min, max); 
}

Isn’t that would give him the same number every time ??

Edit:

So my question will become: How does Random choose its seed? a constant or current time value?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:47:47+00:00Added an answer on May 18, 2026 at 8:47 pm

    It will give the same result when the method will be called often between short time intervals. This is because the Randoms seed is initialized with the current time value.
    This is also the reason why many people have problem of kind that random is not random at all.

    BTW it is not Math.Random but System.Random


    Following your edit, here is some information on how random is initialized. The information comes from the link above.

    The random number generation starts
    from a seed value. If the same seed is
    used repeatedly, the same series of
    numbers is generated. One way to
    produce different sequences is to make
    the seed value time-dependent, thereby
    producing a different series with each
    new instance of Random. By default,
    the parameterless constructor of the
    Random class uses the system clock to
    generate its seed value, while its
    parameterized constructor can take an
    Int32 value based on the number of
    ticks in the current time. However,
    because the clock has finite
    resolution, using the parameterless
    constructor to create different Random
    objects in close succession creates
    random number generators that produce
    identical sequences of random numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I have just integrated my design built using twitter bootstrap, html5, css, jquery with
I have just started PHP and mySQL and need to know if this is
I just passed my application in his production environment : debian nginx unicorn mysql
If I have a function that's passed this function: function(work) { work(10); work(20); work(30);
To this day, I have not found a great article about expressions - and
I'm using dynamic attr_accessible as per this article: http://asciicasts.com/episodes/237-dynamic-attr-accessible It works fine. But I
I have the following code: address = #{(article/div.address).inner_html.strip_html.squish} (using Hpricot) And in some instances...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.