David Hayden recently blogged about Asymmetric Accessor Accessibility in the CLR 2.0 version of C# and VB.NET. If you're not sure what it is, go read his post - it does a great job of explaining it. Just glace at his first example and you'll know exactly what it is. Anyway, this feature specifically caught my attention because (a) I had not heard of it before and (b) I just had a need for it yesterday but had no idea that it was possible in any language. Unfortunately, we have not yet had the chance to convert our 1.1 code to 2.0, so it may be a while before I can get my hands on this functionality.
So in the interim, what's the next best solution? I went with a public read-only property and a protected "setter" method. What other ways could this be done? Please comment!
Private _busy As Boolean = False
Public ReadOnly Property Busy() As Boolean
Get
Return _busy
End Get
End Property
Protected Sub SetBusy(ByVal busy As Boolean)
If busy <> _busy Then
_busy = busy
OnBusyChanged(EventArgs.Empty)
End If
End Sub
I would have preferred that the getter and the setter have the same name and be a part of the same property, but I guess I'll have to wait for 2.0 for that.