Do you know how you can unsubscribe from anonymous method?(rredcat.blogspot.com)
submitted by
RredCat(299) 2 years, 9 months ago
Anonymous Methods is a useful feature which we receive in Framework 2.0. It allows to easy pass a small code block as a delegate parameter (you can set a large block code but this code will be harmful because it is complex and isn't clear for perception). For example:
button1.Click += delegate
{
MessageBox.Show( "Anonymous" );
};
But I have one trouble. What can I do if I want to unsubscribe from event. Seems it is subscribed finally, isn't it?.. Noup! If we declare instance of delegate before define we can unsubscribe a event from this delegate in the code block. For example:
|category: C#
|Views: 14
tags:
C# another
Everyones tags:
Your Tags: