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 7066651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:06:24+00:00 2026-05-28T05:06:24+00:00

To clarify, multiple students objects and all of them are getting the same value.

  • 0

To clarify, multiple students objects and all of them are getting the same value.

I know this question has been asked before, but I have had no luck with the other posts about his topic. I have a random number generator ranging from 1-3. I then us %2 to make a bool value true or false. Every time I run the program I either get all true or all false. Here is my code. I know that random is not really random. What can I do to get more random numbers.

Random random = new Random();

public Student()
{
    int randomLevel=random.Next(1,3);
    level = (randomLevel % 2 == 0);
}

public bool readingLevel()//this always returns one value for the entire program.
{
    return level;
}
  • 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-28T05:06:25+00:00Added an answer on May 28, 2026 at 5:06 am

    You are only assigning a random value to ‘level’ once during the constructor, so it will always have the initial value.
    Try:

    public bool readingLevel()
    {
         return (random.Next(1,3) % 2 == 0);
    }
    

    Edit:

    Static Random random = new Random();
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to clarify one thing. This is not a question on which
I am writing to clarify some comments on this website. 1) I know that
Let me clarify: I am building a relatively simple brochure site that has multiple
Just to clarify, when I say multiple assigment, parallel assignment, destructuring bind I mean
Can you make file copying faster through multiple threading? Edit : To clarify, suppose
I've been asked to go through an existing ASP.NET application and Document the logic
I have a web app built with html5 boilerplate that has multiple skins available.
[ EDIT ] ==> To clarify, in those environments where multiple targets are deployed
I have a csv that I have imported that has multiple data fields for
I haven't had any issues using the same lock for multiple methods so far,

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.