readonly property versus a function

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Aside from a property being able to show up in the forms designer, is there
any reason - other than adhering to a particular coding convention for its
own sake - to use a readonly property instead of a function? I assume
they're equivalant in performance.

Paul
 
Paul said:
Aside from a property being able to show up in the forms designer, is
there
any reason - other than adhering to a particular coding convention for
its
own sake - to use a readonly property instead of a function? I assume
they're equivalant in performance.


The reason is that they are used to implement different things. Properties
are used to implement an entity's (class) attributes while methods are used
to implement operations the entitiy can perform. In practice methods are
favored over properties if executing the property's 'Get' method takes a
long time, for example, when retrieving data from the internet or a
database, or when performing complex calculations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top