T
Tony Johansson
Hello!
Delegate is normally set up in this way using the += construction.
Here an example on event Elapsed in class Timer.
pollTimer.Elapsed += new ElapsedEventHandler(CheckForMessage);
where method CheckForMessage has signature
private void CheckForMessage(object sender, ElapsedEvebtArgs e)
{}
Here I have Comparison<T>. This is a delegate type that can be used for
sorting when the delegate
method has this signature
int method (T objectA, objectB) {}
This construction
Comparison<Vector> sorterDelegat = new Comparison<Vector>
(someSuitableMethodForSort);
works fine setting up a delete method that can be used for example when
sorting
But why is is it not possible to use += in this way. If I try with += I get
compiler error
because the syntax is not understandable by the compiler.
Comparison<Vector> sorterDelegat += new Comparison<Vector>
(VectorDelegates.Compare);
This work always when setting up a delegete method that can be used when the
event is trigged.
//Tony
Delegate is normally set up in this way using the += construction.
Here an example on event Elapsed in class Timer.
pollTimer.Elapsed += new ElapsedEventHandler(CheckForMessage);
where method CheckForMessage has signature
private void CheckForMessage(object sender, ElapsedEvebtArgs e)
{}
Here I have Comparison<T>. This is a delegate type that can be used for
sorting when the delegate
method has this signature
int method (T objectA, objectB) {}
This construction
Comparison<Vector> sorterDelegat = new Comparison<Vector>
(someSuitableMethodForSort);
works fine setting up a delete method that can be used for example when
sorting
But why is is it not possible to use += in this way. If I try with += I get
compiler error
because the syntax is not understandable by the compiler.
Comparison<Vector> sorterDelegat += new Comparison<Vector>
(VectorDelegates.Compare);
This work always when setting up a delegete method that can be used when the
event is trigged.
//Tony