Assigning a named method to a delegate

suggest change

Named methods can be assigned to delegates with matching signatures:

public static class Example
{
    public static int AddOne(int input)
    {
        return input + 1;
    }
}

Func<int,int> addOne = Example.AddOne

Example.AddOne takes an int and returns an int, its signature matches the delegate Func<int,int>. Example.AddOne can be directly assigned to addOne because they have matching signatures.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Delegates:
* Assigning a named method to a delegate

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
94 Delegates
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script