c# - Delegates are immutable but how? -


what happens when add method existing delegate? mean when added method1 del, del holds address of method1. when add method2 afterwards, del still points method1 , method 2 address inserted on bottom of it. doesn't mean changed delegate? if can change why in books told "delegates immutable" ?

mydel del = method1;  del += method2;  del += method3; 

let me use simple analogy. int immutable, when put

int x = 123; x += 1; 

it means

int _x = x + 1; x = _x; 

when adding 1 new temporary variable _x , drop initial x substituting _x; in case of delegates

del += method2;  

means quite same:

delegate _del = delegate.combine(del, method2); del = (mydel) _del; 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -