difference between properties and method in vb

Posted by Shanky11 under VB.NET on 4/29/2013 | Points: 10 | Views : 2718 | Status : [Member] | Replies : 1
what is the difference b/w properties and method in vb.???????????????????????
class and module


Posted by: Satyapriyanayak on: 4/29/2013 [Member] [MVP] Silver | Points: 25

In most cases, properties represent data, and methods perform actions. Properties are accessed like fields, which makes them easier to use. If a method takes no arguments and returns an object's state information, or accepts a single argument to set some part of an object's state, it is a good candidate for becoming a property.

Properties should behave as if they are fields; if the method cannot, it should not be changed to a property. Methods are preferable to properties in the following situations:
· The method performs a time-consuming operation. The method is perceivably slower than the time it takes to set or get a field's value.
· The method performs a conversion. Accessing a field does not return a converted version of the data it stores.
· The "Get" method has an observable side effect. Retrieving a field's value does not produce any side effects.
· The order of execution is important. Setting the value of a field does not rely on other operations having occurred.
· Calling the method twice in succession creates different results.
· The method is static but returns an object that can be changed by the caller. Retrieving a field's value does not allow the caller to change the data stored by the field.


If this post helps you mark it as answer

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response