What is the difference between property and method?
Answer Posted / ravi
Properties are a useful way of expressing a feature of an object, allowing get/set in a common way that can be used by APIs like data-binding, reflection and serialization. So for simple values of the object, properties are handy. Properties can't take arguments, should not have significant side-effects*, and should return quickly and repeatably. Also, there is no such thing as an "extension property" (to mirror an extension method) nor a generic property.
(*=lazy loading etc isn't uncommon, however)
Methods (C# doesn't have functions) are better for expressing things that either change the state, or which have an expectation of taking some time and not necessarily being reproducible. They don't tend to work in binding / serialization etc.
Note that properties are actually just a special way of writing methods. There is little functional difference. It is all about expressing intent. The one thing you don't want to expose, however, is fields (the actualintEmployeeAge instance variable).
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
Explain in brief about the quicktest professional (qtp) automation object model?
What is Associate Repository in QTP 9.2 ?
In an interview, what r the general questions asked in SQL which is realted to testing ?pls give me anwser to this question?
Brief the process of testing with UFT?
Explain the concept of object repository & how qtp recognizes objects?
In qtp, how you can use xpath to identify objects?
How to modify object property in qtp ?
How many types of object repository in qtp?
PLEASE TELL ME WHEN DO YOU USE THE OBJECT SPY AT RUN TIME
In QTP can we feed the out of one browser(internet explorer) as an input to the another browser(mozilla firefox)? If yes explain how to do it with an example.
Get the count of files of similar types from a folder.
How many types of status are there?
How to use actions in qtp ?
How can you identify the browser and its information using the qtp script?
How QTP identify the system time that's changes every seconds?