ایک delegate ایک method کا type-safe reference ہے (function pointer کی طرح) — یہ آپ کو methods کو data کے طور پر سلوک کرنے دیتا ہے: انہیں store کریں، arguments کے طور پر pass کریں، اور انہیں invoke کریں۔ Events delegates پر بنایا گیا ایک pattern ہے جو publish-subscribe (observer) model کے لیے ہے۔ یہ C# میں callbacks، LINQ، اور event-driven programming کی بنیاد ہے۔
Delegates — methods کو values کے طور پر
;
Operation = (a, b) => a + b;
Operation multiply = (a, b) => a * b;
result = (, );
=> op(x, y);
Apply(multiply, , );
