Thursday, January 19, 2006
« WinFX December CTP Install | Main | MSDN Library Install »

David Hayden recently blogged about Asymmetric Accessor Accessibility in the CLR 2.0 version of C# and VB.NETIf 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.

Thursday, January 19, 2006 9:55:56 AM (Central Standard Time, UTC-06:00)
From what I understand, that is essentially the only way to get the same functionality in .NET Framework 1.1. I ran into it with some of our 1.1 code recently as well. I'm just glad that it is available in both C# and VB 2.0! (unlike anonymous delegates!)
Monday, January 23, 2006 9:29:37 PM (Central Standard Time, UTC-06:00)
I feel your pain, but at least 2.0 lets you do this.

BTW: I agree with you 100% on the EmailSending and EmailSent properties. In fact I use this naming on other controls. God only knows why I didn't on the show - I should have.

Thanks for calling me on it,
Miguel
Tuesday, January 24, 2006 4:07:24 PM (Central Standard Time, UTC-06:00)
Miguel,

Thanks for the comments. For anyone else that is interested in seeing what caused the commentary on "EmailSending and EmailSent", see http://www.dnrtv.com/default.aspx?showID=1

I highly recommend it!
Name
E-mail
(will show your gravatar icon)
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):