Just wondering what's the difference of usage of passing data by parameters with passing data through class properties ??
Thanks...
Printable View
Just wondering what's the difference of usage of passing data by parameters with passing data through class properties ??
Thanks...
A property could be considered some inherent trait of the object, while method arguments are just the data required by that method. The two overlap when you are talking about constructor arguments, but that's a special case.
Still dont get you...
Do you mind posting some example of the differennt usage of those two ??
Let's say you are talking about a hypothetical Person class. The Person class might have properties like Name, Age, Height, etc. These are attibutes inherent to a Person object. The Person class might also have a Walk method that takes as arguments a distance and a direction. The distance and direction arguments are the data necessary to execute the Walk method, but they are not actually attributes of the Person object that is doing the walking.
There can also be another type of overlap between properties and methods, like the Visible property of a Form and its Hide and Show methods. Hide and Show set the Visible property to False and True respectively. There are no arguments in this case though. Basically, a property is something an object HAS and a method is something it DOES, with the method arguments being the information it needs to do that thing.
Cool... Thanks a lot :)