 | Create Deligate |
| using System;
| | 1:
| | 2:namespace Arindam.CSharp
| | 3:{
| | 4:
| | 5: public enum Status {High,Medium,Low}
| | 6:
| | 7: /*
| | 8: Now create the delegate. this delegate will have a return void type and take ETGCarEvetArgs as argument.
| | 9: * The delegate does not have to be declared inside a class. All our event handlers will have the same signature as this delegate.
| | 10:
| | 11: But Delegate can be of any type, void/int/string/bool/or any custom type
| | 12: *
| | 13: * Also we can create a generic delegate [shown in third example]
| | 14: */
| | 15:
| | 16:
| | 17: // Delegate 1. custom return type
| | 18: public delegate Status ETGStatusEventhandler(ETGCarEvetArgs args);
| | 19:
| | 20: // Delegate 2. custom return type
| | 21: public delegate void ETGEventhandler(object sender, ETGCarEvetArgs args);
| | 22:
| | 23: // Delegate 3. this is how we use generic to create a delegate
| | 24: public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e);
| | 25:
| | 26:
| | 27:
| | 28:
| | 29:
| | 30:}
| | 31: |
|