Beginner's "-=" question

    Date: 09/03/09 (C Sharp)    Keywords: java

    There are several ways to listen to an event with "+=". As a primarily-Java programmer I'm particulally drawn to the anonymous delegate. But if you want to subsequently remove the listener with -=, how can you identify the object? I guess it is not possible with the anonymous case, but even when you specify

    MyEvent += MyInstanceMethod

    a delegate for the MyInstanceMethod is being created... so will -= MyInstanceMethod remove the same object from the event's colection of listeners? Or do I have to create an explicit "new" instance of a delegate type, keep it on a field and "-=" the field?

    Source: http://csharp.livejournal.com/104768.html

« My open source project || Writing namespace to an XML... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home