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

  • Home
  • SEARCH
  • 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 6662969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:26:53+00:00 2026-05-26T02:26:53+00:00

I have a boolean which is set to false when being declared, public bool

  • 0

I have a boolean which is set to false when being declared,

public bool row1 = false;

However, when I run some code in order to set the boolean to true, it doesn’t seem to be wokring,

if (currentBox.BackColor == cardColour)
{
    MessageBox.Show("Please Draw a Card.");
}
else if (currentBox.BackColor != cardColour)
{
    row = true;
}

The above code is the method body of a method which is being called in a picturebox mouse click event method (using row1 in the parameters when calling the method). At its current state, it’s saying it’s false when it should be set to true.

Here is the code which is calling the method.

private void rowOne_MouseClick(object sender, MouseEventArgs e)
{
    AllowTake(row1, currentCardPictureBox, Color.White, sender, e);
}

Thanks for any help.

  • 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-26T02:26:53+00:00Added an answer on May 26, 2026 at 2:26 am

    You should pass the row parameter by ref: row1 is a separate local variable and its value is not used outside the method.

    void MakeTrue(bool flag) {
        flag = true;
    }
    
    //Calling code:
    bool myFlag = false;
    MakeTrue(myFlag);
    

    After MakeTrue is called the value of myFlag doesn’t change. Its value is used to initialize a flag argument in MakeTrue method and that’s it. After that whatever you do to flag won’t affect the value of myFlag.

    Now, if you do this:

    void MakeTrue(ref bool flag) {
        flag = true;
    }
    
    //Calling code:
    bool myFlag = false;
    MakeTrue(ref myFlag);
    

    you will get the desired (in your case) behavior: flag will be just an alias for myFlag variable and whatever you assign to it will become the value of myFlag.

    Some links to read:

    • Passing parameters (MSDN)
    • Parameters passing in C#
    • Why ref and out in C#.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model which has a boolean property and some other properties that
I have a set of model objects that have a public IsVisible boolean property.
Since MySQL doesn't seem to have any 'boolean' data type, which data type do
I have a table which has essentially boolean values in a legacy database. The
I have CustomForm inherited from Form which implements a boolean property named Prop .
I have an class which has a enum property and a boolean property, based
I have a strange problem which I can't fix: A field: private boolean[][][] gaps;
I have an SSIS package, which depending on a boolean variable, should either go
I have a table named categories, which contains ID(long), Name(varchar(50)), parentID(long), and shownByDefault(boolean) columns.
I have an Auction model with several attributes, two of which are current_auction:boolean and

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.