A common scenario is when you define a custom event in your component - you don't know which is the method/function to be called when event is raised. So, you let the component user to indicate it.
Make it sense?
More details here:
2006年10月30日 上午 07:28
I don't know what you mean by quality of OOPs, but it achieves the same things as get/set methods in a C++ or Java program. Though, in my opinion, the syntax for properties is more expressive. Additionally, it clearly delineates what an object's properties are, whereas this isn't so clear in a Java class. This helps when making tools that use reflection to manipulate an object at design time.2006年10月30日 下午 02:50
Debabrata.debroy wrote: I got the first answerr now my second question was what quality of OOPs we got through property in dot net.
They needed a concept between method and field, and they invented it: properties. Which were the possibilities we had before to expose a class field?
2006年10月30日 下午 04:58
- Create a method which returns the private field, but where is the behavior of this method?
- Exposing the class field (i.e. make it public) would break on of OOP concept: encapsulation.