Information Technology Reference
In-Depth Information
Read-Only and Write-Only Properties
You can leave one or the other of a property's accessors undefined by omitting its declaration.
A property with only a get accessor is called a read-only property. A read-only property
is a safe way of passing an item of data out from a class or class instance without allowing
too much access.
￿
A property with only a set accessor is called a write-only property. A write-only property
is a safe way of passing an item of data from outside of the class to the class without
allowing too much access.
￿
￿
At least one of the two accessors must be defined; otherwise, the compiler will produce
an error message.
Figure 6-10 illustrates read-only and write-only properties.
Figure 6-10. A property can have one or the other of its accessors undefined.
Search WWH ::




Custom Search