Home
About
Projects
Courses
Blogs
Blogs
Contact
The Forge LogoThe Forge Logo|

© 2026 Youssef Elmohamadi The Forge. All rights reserved.

ON THIS PAGE

Delegates in C# – A Complete Beginner’s Guide

5 days ago
5 min read
40

Introduction

As you learn C#, you'll encounter many concepts that might seem complicated or confusing at first. However, once you understand the ideas behind them, you'll realize how much they simplify the way you write and structure your code. One of these concepts is Delegates. Imagine you have a method that you want to pass to another method so it can use it internally. Or perhaps you want to store a method in a variable and execute it later, depending on your application's needs. Is that possible? Absolutely! And that's exactly what delegates allow us to do. A Delegate is a type that holds a reference to a specific method. It allows us to work with methods in a flexible way, meaning we can store them in variables, pass them as parameters to other methods, and invoke them whenever we need. However, keep in mind that you can't assign just any method to any delegate. The method must match specific requirements known as its Signature. A method's signature, in this context, defines its return type and the number, types, and order of its parameters. You can think of a delegate as a Contract that defines the structure of the methods it can reference and invoke.

What Is a Delegate?

Simply put, a Delegate is a type that allows us to store a reference to a method and then invoke that method through the delegate itself. Let's understand this with an example. Imagine you have an application that can greet users in multiple languages, such as English and Spanish. Instead of calling each method directly, we can use a single delegate and control which method gets executed through it.

Defining a Delegate

First: Declare the Delegate We use the delegate keyword to define a new delegate type:

javascript
1public delegate void GreetDelegate(string name);

Let's break this declaration down step by step: public: Specifies that the delegate is accessible from outside its declaring scope, subject to the accessibility of its containing type. delegate: The keyword used to declare a delegate type. void: Specifies that methods assigned to this delegate must not return a value. GreetDelegate: The name of the delegate. string name: The parameter that the method must accept. Here's an important point to remember: We're not creating a method here. We're defining a new Type that specifies the structure of the methods we can assign to it. Second: Create Methods That Match the Delegate's Signature

javascript
1public class Greeter
2{
3    public void EnglishGreeting(string name)
4    {
5        Console.WriteLine($"Hello, {name}!");
6    }
7
8    public void ArabicGreeting(string name)
9    {
10        Console.WriteLine($"اهلا, {name}!");
11    }
12}

Here, we have two methods: EnglishGreeting: Prints a greeting message in English. ArabicGreeting: Prints a greeting message in Arabic. But why can we use both methods with GreetDelegate? Simply because they have the same Signature: Return Type: void Parameters: string And that's exactly what the delegate defines. Third: Using the Delegate

javascript
1class Program
2{
3    static void Main()
4    {
5        Greeter greeter = new Greeter();
6
7        GreetDelegate greet = greeter.EnglishGreeting;
8        greet("Alice");
9
10        greet = greeter.ArabicGreeting;
11        greet("احمد");
12    }
13}

Let's understand what's happening step by step: 1. Create an Object from the Class

javascript
1Greeter greeter = new Greeter();

We create an object so we can access and use the methods defined inside the Greeter class. 2. Assign the First Method to the Delegate

javascript
1GreetDelegate greet = greeter.EnglishGreeting;

We create a variable named greet of type GreetDelegate and assign the EnglishGreeting method to it. Notice that we write the method name without parentheses (). That's because we don't want to execute the method right now. We simply want to assign its reference to the delegate. 3. Invoke the Delegate

javascript
1greet("Alice");

Now, when we invoke the delegate, the method assigned to it gets executed.

javascript
1Hello, Alice!

After that, we changed the method the delegate was pointing to.

javascript
1greet = greeter.ArabicGreeting;
2greet("احمد");

And here's the result:

javascript
1اهلا, احمد!

Notice that we used the same delegate, but changed the method assigned to it. This is one of the most important advantages of delegates: you can change the behavior being executed without changing the way you invoke the delegate itself.

Why Do We Use Delegates?

You might be asking yourself: Why do we need delegates in the first place? Why not just call methods directly? The truth is that delegates give us more flexibility when writing code. They help us separate different parts of an application and reduce code duplication. Let's explore some of their most important use cases. 1. Decoupling Application Components Imagine you have two components in your application that need to interact with each other, but you don't want either component to know the internal implementation details of the other. This is where delegates help us reduce coupling between components. How does it work? Instead of making one part of the application directly depend on a specific method, we can make it accept a delegate. The other part is then responsible for deciding which method gets executed. This makes our code more flexible and maintainable. You'll see this concept clearly in Events, which are built on top of delegates.

Passing Behavior as a Parameter

This is one of the most powerful features of delegates. We're used to passing data such as string or int when calling a method. But with delegates, we can pass a method itself! In other words, instead of passing only Data, we can also pass a specific way of performing an operation (Behavior). The method receiving the delegate can then invoke the behavior that was passed to it. This concept is one of the fundamental building blocks behind Callback Functions.

Working with Events

Delegates are the foundation of the Events system in C#. For example, when a user clicks a Button, an event is triggered. Any part of the application that has subscribed to that event can respond and execute its own code. We'll explore the relationship between delegates and events in more detail later in this article.

Code Reusability

Imagine you have a method that performs a specific operation, but one part of that operation needs to behave differently depending on the situation. Instead of creating a separate method for each case and duplicating the same code, you can make the method accept a delegate and execute the behavior passed to it. This allows you to reuse the same Logic with different behaviors without repeating code.

Built-in Delegate Types in C#

So far, we've learned how to define our own delegates using the delegate keyword. But imagine having to declare a new delegate type every time you need one! That would introduce unnecessary repetition. That's why C# provides a set of built-in delegate types inside the System namespace, which we can use directly. The three most common types are: Action Func Predicate<T> First: Action We use Action when we need a delegate that references a method that doesn't return a value, meaning its return type is void. The method can accept parameters or no parameters at all, depending on which Action type we use. Example:

javascript
1Action<string> print = Console.WriteLine;
2
3print("Using Action delegate!");

Let's break down the code: Action<string>: Means the delegate accepts one parameter of type string. print: The name of the delegate variable. Console.WriteLine: The method assigned to the delegate. print(): We use this to invoke the delegate and execute the associated method. Output:

javascript
1Using Action delegate!

Second: Func We use Func when we need a delegate that references a method that returns a value (Return Value). The method can accept parameters or no parameters at all. However, there's an important rule you need to remember: The last generic type in Func specifies the return type, while all the preceding types represent the parameter types. Example:

javascript
1Func<int, int, int> add = (x, y) => x + y;
2
3Console.WriteLine(add(5, 3));

Let's understand this declaration:

javascript
1Func<int, int, int> add

First int: The type of the first parameter, x. Second int: The type of the second parameter, y. Third int: The type of the value returned by the method. Now, what about this part?

javascript
1(x, y) => x + y

This is called a Lambda Expression, which is a concise way to write a function without having to define a separate method. In other words, we're telling the delegate: When someone invokes you, accept two numbers, add them together, and return the result. When we execute:

javascript
1add(5, 3);

The output will be:

javascript
18

Third: Predicate<T> Predicate<T> is a delegate type that we use when we need a method that accepts a single parameter of type T and returns a bool value. In other words, the result will be either true or false. It's commonly used when we need to check a specific condition or perform filtering operations. Example:

javascript
1Predicate<int> isEven = number => number % 2 == 0;
2
3Console.WriteLine(isEven(10));
4Console.WriteLine(isEven(7));

Here, we created a Predicate<int> that accepts an integer and checks whether the number is even or odd. If the number is divisible by 2 with no remainder, it returns true. Otherwise, it returns false. Output:

javascript
1True
2False

The Difference Between Action, Func, and Predicate

Delegate TypeNumber of ParametersReturn Type
ActionZero or morevoid
FuncZero or moreAny type
Predicate<T>Exactly onebool

خلي القاعدة دي في دماغك: محتاج تنفذ Method ومش محتاج ترجع قيمة؟ استخدم Action. محتاج تنفذ Method وترجع قيمة؟ استخدم Func. محتاج تتحقق من شرط وترجع true أو false؟ استخدم Predicate<T>.

يعني إيه Multicast Delegate؟

لحد دلوقتي إحنا اتعلمنا إن الـ Delegate ممكن يشاور على Method واحدة. طب هل تعرف إنه ممكن يشاور على أكتر من Method في نفس الوقت؟ أيوه، وده اللي بنسميه Multicast Delegate. الـ Multicast Delegate هو Delegate بيقدر يحتفظ بمراجع لأكتر من Method، ولما نستدعيه، كل الـ Methods الموجودة جواه بتتنفذ بالترتيب اللي اتضافت بيه. القائمة دي اسمها Invocation List. والـ Delegates اللي بتدعم الخاصية دي في C# بتكون مشتقة من System.MulticastDelegate. مثال عملي تخيل إن عندك Application مسؤول عن إرسال Notifications للمستخدم، ومحتاج تبعتله إشعار بأكتر من طريقة: Email Notification SMS Notification Push Notification بدل ما تنادي كل Method لوحدها، تقدر تجمعهم كلهم تحت Delegate واحد وتنفذهم باستدعاء واحد.

javascript
1public delegate void Notify();
2
3class Notifications
4{
5    public void EmailNotification()
6    {
7        Console.WriteLine("Email sent.");
8    }
9
10    public void SMSNotification()
11    {
12        Console.WriteLine("SMS sent.");
13    }
14
15    public void PushNotification()
16    {
17        Console.WriteLine("Push notification sent.");
18    }
19}
20
21class Program
22{
23    static void Main()
24    {
25        Notifications notify = new Notifications();
26
27        Notify notifyAll = notify.EmailNotification;
28
29        notifyAll += notify.SMSNotification;
30        notifyAll += notify.PushNotification;
31
32        notifyAll();
33    }
34}

تعالوا نفهم الكود 1. عرفنا الـ Delegate:

javascript
1public delegate void Notify();

عرفنا Delegate اسمه Notify، وبيتعامل مع Methods مش بتستقبل Parameters ومش بترجع أي قيمة. 2. عملنا Object:

javascript
1Notifications notify = new Notifications();

عملنا Object من الـ Notifications علشان نقدر نستخدم الـ Methods الموجودة جواه. 3. ربطنا أول Method:

javascript
1Notify notifyAll = notify.EmailNotification;

عملنا Variable اسمه notifyAll من نوع Notify، وربطناه بالـ EmailNotification. 4. ضفنا باقي الـ Methods:

javascript
1notifyAll += notify.SMSNotification;
2notifyAll += notify.PushNotification;

استخدمنا += علشان نضيف باقي الـ Methods للـ Delegate. دلوقتي الـ Invocation List بقت فيها 3 Methods: EmailNotification SMSNotification PushNotification 5. استدعينا الـ Delegate:

javascript
1notifyAll();

هنا بقى استدعينا الـ Delegate مرة واحدة، فكل الـ Methods اللي موجودة في الـ Invocation List اتنفذت بالترتيب. الناتج:

javascript
1Email sent.
2SMS sent.
3Push notification sent.

إزاي نشيل Method من الـ Multicast Delegate؟

زي ما إحنا استخدمنا += علشان نضيف Methods للـ Delegate، نقدر كمان نستخدم -= علشان نشيل Method معينة من الـ Invocation List. خلينا نرجع لمثال الـ Notifications. افترض إننا مش عايزين نبعت SMS Notification، وعايزين نحتفظ بإرسال Email و Push Notifications بس. هنعمل كده:

javascript
1notifyAll -= notify.SMSNotification;
2
3notifyAll();

هنا استخدمنا -= علشان نشيل SMSNotification من الـ Invocation List. وبالتالي لما نستدعي الـ Delegate تاني، هينفذ الـ Methods اللي لسه موجودة في القائمة. الناتج:

javascript
1Email sent.
2Push notification sent.

طب إيه الفرق بين = و += و -=؟ = بتعمل Assign، ولو فيه Methods مرتبطة بالـ Delegate، بتستبدل القائمة الحالية. += بتضيف Method جديدة للـ Invocation List. -= بتشيل آخر تطابق للـ Method المحددة من الـ Invocation List. وخد بالك، لما تشيل Method من الـ Delegate، ده مش معناه إنك حذفتها من الـ Class نفسه، إنت بس شيلتها من قائمة الـ Methods اللي الـ Delegate هينفذها.

ملاحظات مهمة وقيود الـ Multicast Delegates

فيه شوية نقاط مهمة لازم تاخد بالك منها وإنت بتتعامل مع الـ Multicast Delegates. أولًا: آخر Return Value هي اللي بترجع لما تستخدم Multicast Delegate مع Methods بترجع Values، كل الـ Methods هتتنفذ، لكن القيمة اللي هتستقبلها من استدعاء الـ Delegate هي قيمة آخر Method اتنفذت بس. تعالوا نشوف مثال:

javascript
1public delegate int Calculation();
2
3public static int A()
4{
5    Console.WriteLine("A");
6    return 1;
7}
8
9public static int B()
10{
11    Console.WriteLine("B");
12    return 2;
13}
14
15public static void Main()
16{
17    Calculation calc = A;
18    calc += B;
19
20    int result = calc();
21
22    Console.WriteLine("Result: " + result);
23}

إيه اللي هيحصل هنا؟ هتتنفذ A وهتطبع A وترجع 1. بعد كده هتتنفذ B وهتطبع B وترجع 2. في الآخر قيمة result هتكون 2. الناتج:

javascript
1A
2B
3Result: 2

يعني إيه الكلام ده؟ يعني لو عندك أكتر من Method بترجع قيمة، مش هتستقبل كل القيم مرة واحدة، لكن هتستقبل قيمة آخر Method بس. ولو محتاج تحتفظ بنتيجة كل Method، تقدر تستخدم GetInvocationList() وتنفذ كل واحدة بشكل منفصل. ثانيًا: ترتيب تنفيذ الـ Methods كل الـ Methods الموجودة في الـ Invocation List بتتنفذ بنفس ترتيب إضافتها. يعني لو كتبت:

javascript
1calc = A;
2calc += B;
3calc += C;

الترتيب هيكون: A B C ببساطة، كل Method بتتنفذ حسب مكانها في القائمة. ثالثًا: الـ Exceptions ممكن توقف باقي الـ Methods دي نقطة مهمة جدًا! لو واحدة من الـ Methods حصل فيها Exception ومتمش التعامل معاها، تنفيذ الـ Invocation List هيتوقف، والـ Methods اللي بعدها مش هتتنفذ. مثال:

javascript
1public delegate void Notify();
2
3public static void A()
4{
5    Console.WriteLine("A");
6}
7
8public static void B()
9{
10    throw new Exception("Something went wrong!");
11}
12
13public static void C()
14{
15    Console.WriteLine("C");
16}
17
18static void Main()
19{
20    Notify notify = A;
21    notify += B;
22    notify += C;
23
24    notify();
25}

اللي هيحصل:

javascript
1A
2Unhandled Exception: Something went wrong!

لاحظ إن C متنفذتش، لأن الـ Exception اللي حصلت في B أوقفت استكمال تنفيذ الـ Invocation List. ولو عايز كل Method تتنفذ بشكل مستقل حتى لو واحدة منهم حصل فيها Exception، تقدر تستخدم GetInvocationList() وتتعامل مع كل Method داخل try-catch منفصلة.

إمتى أستخدم Delegate وإمتى Interface أو Event؟

ممكن تكون بتسأل نفسك: طب ما إحنا عندنا Interfaces في C#، وعندنا كمان Events، إيه الفرق بينهم؟ وإمتى نستخدم كل واحد؟ الحقيقة إن كل واحد فيهم ليه استخدام مختلف، والاختيار بينهم بيعتمد على المشكلة اللي بتحاول تحلها.

حالة الاستخدامالاختيار المناسب
عايز تمرر Method واحدة كسلوك قابل للتغييرDelegate
عايز تحدد مجموعة من Methods لازم Class ينفذهاInterface
عايز تعلن إن حاجة حصلت وتسمح لأجزاء تانية تستجيب ليهاEvent

1. Delegate بنستخدم الـ Delegate لما نكون محتاجين نمرر Method كـ Parameter، أو نغير الـ Behavior اللي البرنامج هينفذه وقت التشغيل. مثال: عندك Method مسؤولة عن حساب السعر النهائي، وعايز تحدد طريقة الخصم من بره الـ Method نفسها. ممكن تمرر Delegate يمثل طريقة حساب الخصم، وبكده تقدر تغير طريقة الحساب من غير ما تغير الـ Method الأساسية. 2. Interface بنستخدم الـ Interface لما نكون عايزين نحدد Contract لمجموعة من الـ Classes. يعني بنقول لأي Class هيعمل Implementation للـ Interface دي: لازم يوفر الـ Methods والـ Properties اللي إحنا محددينها. مثال: عندك Application فيه أكتر من طريقة للدفع: CreditCardPayment PayPalPayment CashPayment ممكن تعمل Interface اسمها IPayment، وكل Class ينفذها ويوفر طريقة الدفع الخاصة بيه. وده بيساعدنا نحقق Polymorphism وننظم الكود بشكل أفضل. 3. Events بنستخدم الـ Events لما نكون عايزين جزء من البرنامج يعلن إن حاجة معينة حصلت، ويسمح لأجزاء تانية إنها تستجيب للحدث ده. مثال بسيط: لما المستخدم يضغط على Button، بيحصل Event اسمه Click. الـ Button مش محتاج يعرف إيه الكود اللي هيتنفذ بعد الضغط عليه، هو بس بيعلن إن الحدث حصل، والـ Methods المشتركة في الحدث هي اللي بتنفذ السلوك المطلوب.

استخدامات الـ Delegates في المشاريع الحقيقية

الـ Delegates مش مجرد مفهوم نظري بنتعلمه وخلاص، دي حاجة هتقابلها كتير جدًا وإنت بتشتغل بـ C# و.NET. تعالوا نشوف أشهر الاستخدامات. 1. التعامل مع الأحداث (Event Handling) من أشهر استخدامات الـ Delegates هي التعامل مع الـ Events. زي: Button Clicks. User Interactions. Notifications. Changes in Application State. لما المستخدم يعمل Action معين، الـ Event بيتم إطلاقه، والـ Methods المشتركة فيه بتستجيب للحدث. 2. استخدام LINQ الـ Delegates بتستخدم بشكل كبير مع LINQ، خصوصًا لما نحتاج نعمل Filtering أو عمليات مختلفة على Collections. مثال:

javascript
1var numbers = new List<int> { 10, 15, 20, 25, 30 };
2
3var result = numbers.Where(number => number > 20);

هنا الـ Where بتستقبل شرط بيحدد أنهي عناصر هنحتفظ بيها. الشرط ده مكتوب باستخدام Lambda Expression، وبيتم تمريره كـ Func<T, bool>. يعني بنقول للـ Where: خد كل عنصر، واختبره بالشرط ده، واحتفظ بالعناصر اللي النتيجة بتاعتها true. الناتج هيكون:

javascript
125, 30

وخد بالك من نقطة مهمة: الـ Where بتستخدم Func<T, bool>، مش Predicate<T>، رغم إن الاتنين بيرجعوا bool. 3. استخدام Callbacks الـ Callback ببساطة هي Method بنبعتها لجزء تاني من البرنامج، علشان الجزء ده ينفذها لما عملية معينة تخلص أو يحصل موقف معين. وده من الاستخدامات المهمة للـ Delegates. مثال:

javascript
1public static void DownloadFile(Action onComplete)
2{
3    Console.WriteLine("Downloading file...");
4
5    // Simulate download completion
6
7    onComplete();
8}
9
10static void Main()
11{
12    DownloadFile(() =>
13    {
14        Console.WriteLine("Download completed!");
15    });
16}

تعالوا نفهم اللي بيحصل. عندنا Method اسمها DownloadFile بتستقبل Action اسمه onComplete. بعد ما عملية التحميل تخلص، بنستدعي:

javascript
1onComplete();

وبكده بننفذ الـ Method اللي اتبعتت لـ DownloadFile. الناتج:

الفكرة هنا إن DownloadFile مش محتاجة تعرف إيه اللي المفروض يحصل بعد انتهاء التحميل، هي بس بتنفذ الـ Callback اللي اتبعتلها. ملحوظة: المثال ده توضيحي ومتزامن (Synchronous)، لكن نفس الفكرة ممكن نستخدمها مع العمليات غير المتزامنة (Asynchronous Operations). 4. تطبيق Strategy Pattern الـ Strategy Pattern هو Design Pattern بنستخدمه لما يكون عندنا أكتر من طريقة لتنفيذ نفس العملية، وعايزين نقدر نختار الطريقة المناسبة وقت التشغيل. والـ Delegates ممكن تساعدنا نطبق الفكرة دي، خصوصًا في الحالات البسيطة، من غير ما نحتاج نعمل Class منفصل لكل Strategy. خلينا ناخد مثال. تخيل إن عندك برنامج بيحسب أسعار المنتجات، ومحتاج تدعم أكتر من طريقة للخصم.

javascript
1Downloading file...
2Download completed!

الفكرة هنا إن DownloadFile مش محتاجة تعرف إيه اللي المفروض يحصل بعد انتهاء التحميل، هي بس بتنفذ الـ Callback اللي اتبعتلها. ملحوظة: المثال ده توضيحي ومتزامن (Synchronous)، لكن نفس الفكرة ممكن نستخدمها مع العمليات غير المتزامنة (Asynchronous Operations). 4. تطبيق Strategy Pattern الـ Strategy Pattern هو Design Pattern بنستخدمه لما يكون عندنا أكتر من طريقة لتنفيذ نفس العملية، وعايزين نقدر نختار الطريقة المناسبة وقت التشغيل. والـ Delegates ممكن تساعدنا نطبق الفكرة دي، خصوصًا في الحالات البسيطة، من غير ما نحتاج نعمل Class منفصل لكل Strategy. خلينا ناخد مثال. تخيل إن عندك برنامج بيحسب أسعار المنتجات، ومحتاج تدعم أكتر من طريقة للخصم.

javascript
1public class PriceCalculator
2{
3    public decimal Calculate(
4        decimal price,
5        Func<decimal, decimal> discountStrategy)
6    {
7        return discountStrategy(price);
8    }
9}

دلوقتي نقدر نمرر طرق مختلفة لحساب الخصم:

javascript
1static void Main()
2{
3    PriceCalculator calculator = new PriceCalculator();
4
5    Func<decimal, decimal> regularDiscount =
6        price => price * 0.90m;
7
8    Func<decimal, decimal> specialDiscount =
9        price => price * 0.70m;
10
11    decimal price = 1000m;
12
13    Console.WriteLine(
14        calculator.Calculate(price, regularDiscount)
15    );
16
17    Console.WriteLine(
18        calculator.Calculate(price, specialDiscount)
19    );
20}

الناتج:

javascript
1900
2700

لاحظ إننا استخدمنا نفس الـ Calculate Method، لكن غيرنا طريقة حساب الخصم عن طريق تغيير الـ Delegate اللي بنمرره ليها. وده بيوضح إزاي نقدر نغير الـ Behavior وقت التشغيل من غير ما نضطر نغير الـ Logic الأساسي.

فين هنقابل Delegates داخل .NET؟

الـ Delegates مستخدمة في أجزاء مهمة جدًا من .NET، ومن أشهر الأمثلة: نظام الـ Events: بيعتمد على Delegates علشان يسمح لأكتر من Method إنها تشترك في نفس الحدث وتستجيب ليه. LINQ: بيستخدم أنواع زي Func<T, bool> علشان نقدر نمرر شروط وعمليات مختلفة لـ Methods زي Where وSelect. يعني فهمك للـ Delegates مش هيفيدك في المثال اللي شرحناه بس، لكنه هيساعدك تفهم حاجات كتير هتقابلها باستمرار وإنت بتكتب C#.

الخلاصة

وبكده نكون وصلنا لنهاية شرح الـ Delegates. خلينا نراجع بسرعة أهم الحاجات اللي اتعلمناها:

المفهوممعناه
DelegateType بيحتفظ بمرجع لـ Method مطابقة لـ Signature معينة
Multicast DelegateDelegate يقدر يحتفظ بمراجع لأكتر من Method
Invocation Listالقائمة اللي فيها الـ Methods المرتبطة بالـ Delegate
ActionDelegate للـ Methods اللي بترجع void
FuncDelegate للـ Methods اللي بترجع قيمة
Predicate<T>Delegate بيستقبل Parameter واحد وبيرجع bool
Eventطريقة للإعلان عن حدوث شيء والسماح للأجزاء المهتمة بالاستجابة ليه

أهم حاجة عايزك تطلع بيها من الموضوع ده إن الـ Delegate مش مجرد طريقة تانية لاستدعاء Methods. الفكرة الأساسية إنه بيدينا إمكانية نتعامل مع الـ Methods كأنها Values، نقدر نخزنها ونبعتها لـ Methods تانية ونغير الـ Behavior اللي البرنامج بينفذه وقت التشغيل. وده هيساعدك تفهم مفاهيم تانية مهمة جدًا في C# زي الـ Events والـ Lambda Expressions والـ LINQ والـ Callback Functions والـ Design Patterns. ونصيحتي ليك: متحاولش تحفظ الـ Syntax والأمثلة وخلاص، حاول تفهم كل سطر بيعمل إيه وليه استخدمناه، وجرب تكتب الأمثلة بنفسك وتغير فيها. لأن الفرق الحقيقي مش إنك تعرف تكتب Delegate، لكن إنك تعرف إمتى وليه تستخدمه في مشروع حقيقي.

Enjoyed the read? Share it!

Share Article: