Write-Only Properties

Opposite to read-only properties, you can also implement write-only properties. In real-life applications, write-only properties are uncommon, so you will probably never implement such members. It makes much more sense providing read-only members than members that you can only write to but not read from. Anyway, you can implement write-only properties marking your properties with the WriteOnly keyword as demonstrated in the following code snippet:

image

You have different options here; one is storing the value received by the setter within a field that you can then eventually reutilize. Otherwise, you can perform some tasks directly ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.