6 Replies - 5123 Views - Last Post: 26 December 2013 - 09:01 AM Rate Topic: -----

#1 charlay13  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 23-August 13

Changing property value using "if" statements

Posted 23 December 2013 - 03:13 PM

Hi I have a relatively simple question. I am trying to change a value based on another property, using a method with parameters here is my code:

       public void roeRATE(double Input, ref int Display)
            {
                if (Input > 25)
                {
                    Display = Display + 6;
                }
                if (Input < 15)
                {
                    Display = Display + 4;
                }
                else
                {
                    Display = Display + 5;
                }
            }     



Is this best way to change a property/parameter named "Display"?

Is This A Good Question/Topic? 0
  • +

Replies To: Changing property value using "if" statements

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5677
  • View blog
  • Posts: 12,208
  • Joined: 02-June 10

Re: Changing property value using "if" statements

Posted 23 December 2013 - 03:27 PM

Nothing wrong with that, that I see.
Was This Post Helpful? 0
  • +
  • -

#3 charlay13  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 23-August 13

Re: Changing property value using "if" statements

Posted 24 December 2013 - 09:26 AM

Thanks. What if I had multiple methods like this, all altering the value of the parameter filling the spot of "Display"? Should I still use "ref" or what is the best way to do that?
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5677
  • View blog
  • Posts: 12,208
  • Joined: 02-June 10

Re: Changing property value using "if" statements

Posted 24 December 2013 - 09:40 AM

Give a man a fish and he eats for a day, teach a man to fish and he eats for a lifetime.

Which is my way of saying: "Have you read about the ref keyword? What does it do and what does it do for you? If you comprehend it, then you should be able to decide if you need it or not.

Have you just tried playing with your code? Make multiple methods changing the property "Display". Have some them use the ref keyword, and have some of them not. What happens?

You have the tools in front of you to learn these things, without someone hand holding you, or being your free private tutor.

If after doing some experimenting and reading, you should have some questions about your *results* please jump back on and ask them. We are always happy to clear up misunderstanding, just not so quick to give you all the answers so you don't have to do any work to learn them on your own.
Was This Post Helpful? 0
  • +
  • -

#5 charlay13  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 23-August 13

Re: Changing property value using "if" statements

Posted 24 December 2013 - 01:16 PM

If there's something I dislike more than arrogance, it's pretentious arrogance. Outcasts in high school turn into pretentious douchebags.

Thanks for all your help
Was This Post Helpful? -1
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5677
  • View blog
  • Posts: 12,208
  • Joined: 02-June 10

Re: Changing property value using "if" statements

Posted 26 December 2013 - 08:10 AM

And here I thought I was doing a pretty good job of not calling you "Too lazy to do their own reading or experimenting".

The best of holiday wishes to you too.
Was This Post Helpful? 0
  • +
  • -

#7 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Changing property value using "if" statements

Posted 26 December 2013 - 09:01 AM

Please keep a civil tone when posting. We do not tolerate personal attacks against other members. Feel free to object to what they say, but do so without the rude personal commentary.

As this thread has now spiraled into this nonsense, I'm closing it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1