Possible Duplicate:
Making a generic property
I’m not quite sure how to do that, but what I would like to do is to create a special type of property that will perform specific tasks at the get and set, and will be defined on generic type.
For example, when writing this:
MyProp<String> name;
a pre-defined get and set will be performed on the string value.
How can that be done?
Thanks!
You can make a generic class like this:
…then use it in a class like so:
The implicit operators means that you do not need to explicitly set or get the
Valueproperty ofMyProp, but can write code to access the value in a more “natural” way: