---
title: "Delegates in C#"  
description: "Delegates in C#"  
author: "Anonymous User"  
published: 2015-12-21  
updated: 2015-12-21  
canonical: https://www.mindstick.com/forum/33765/delegates-in-c-sharp  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 1 minute  

---

# Delegates in C#

I want to use [Delegates in c#](https://www.mindstick.com/forum/155584/give-a-detailed-explanation-of-delegates-in-c-sharp) please help me how to use this.

## Replies

### Reply by Anonymous User

C# delegates are similar to pointers to functions, in C or C++. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.

Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.

```
using System;delegate int ReplaceNumber(int n);namespace DelegateApp{   class UseDelegate   {      static int number = 10;      public static int AddNumber(int p)      {         number += p;         return number;      }      public static int MultNumber(int q)      {         number *= q;         return number;      }      public static int getNumber()      {         return number;      }      static void Main(string[] args)      {         //create delegate instances         ReplaceNumber numberc1 = new ReplaceNumber(AddNumber);         ReplaceNumber numberc2 = new ReplaceNumber(MultNumber);                  //calling the methods using the delegate objects         numberc1(25);         Console.WriteLine("First Value of Number: {0}", getNumber());         numberc2(5);         Console.WriteLine("Second Value of Number: {0}", getNumber());         Console.ReadKey();      }   }}
```

![Delegates in C#](https://www.mindstick.com/mindstickforums/3b884ee5-2295-4c3b-a464-575f99c85a33/images/b7e80f2e-6d5e-4a7b-9369-5f12d3f94f58.png)


---

Original Source: https://www.mindstick.com/forum/33765/delegates-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
