Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to learn when I should use a method and when should I use property? I am trying to write a one line routine that multiplies 2 denominators of a fraction together. Should I use a method or property I have a class that has the numerator and denominator in it and I would like to know it is good programming practice to do calculations in a property?

 

JOHN

:confused: :confused: :confused:

  • *Experts*
Posted

A "side effect" would be changing the value that the user passed

into a function without them expecting it, which is not usually

done in a property accessor. Like Robby said, functions should be

used to change and return values.

 

For example, it's more advisable to have a Disconnect() method

than to have the user set the Connected property to false.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted
So if had to calculate and output a common denominator in a textbox. ie: Switch the value to the common denominator calcultion I should use a property?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...