Skip to content

Assigning Delegates

Because delegates are reference types, you can change the reference contained in a delegate variable by assigning to it. The old delegate object will be disposed of by the garbage collector (GC) when it gets around to it.

For example, the following code sets and then changes the value of delVar. Below figure illustrates the code.

Leave a Reply

Your email address will not be published. Required fields are marked *