Skip to content

C Sharp if statement concerning button color.

David

Asked Mar 3, 2008, 10:21 AM EST2 answers
Share
LinkedInX
What is the proper syntax to perform and if statement concerning a buttons color.

Sample code that is non-working:

                if (this.btnChat1.BackColor="Color.Salmon")
                {
                    this.btnChat1.BackColor = Color.DarkBlue;
                }
                else
                {
                    this.btnChat1.BackColor = Color.Salmon;
                }

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Fixed Code by utilizing == in an if statement instead of =.

    DOH!

    0
  • 0
    You have to use == in ifcondition, as = is an assignment operator in C#. For comparing two values you have to use ==.
    0