Dear CSharp Group,
Both of these techniques work as expected but what is the better way of
doing this? Or does it even make a difference?
Method 1:
public delegate void MyDelegate(string s); //delegate
List<MyDelegatelistOfDelegates = new List<MyDelegate>(); //Generic
List of Delegates
listOfDelegates.Add( myFunc1 );
listOfDelegates.Add( myFunc2 );
Method 2:
listOfDelegates.Add( new MyDelegate(myFunc1) );
listOfDelegates.Add( new MyDelegate(myFunc2) );
So when I loop through my list I can call the functions and they both
work the same. Is one method more better then the other? All I can
tell is that the 2nd method I'm first creating a new Delegate and
passing in my function then adding it. The first method doesn't create
the new Delegate object.
So which is recommended and can I get bad side effects with one way or
the other?
Thanks in advance guys.