Assigning a named method to a delegate C# with Example



Assigning a named method to a delegate C# with Example

Named methods can be assigned to delegates with matching signatures: 
public static class Example 
{ 
public static int AddOne(int input) 
{ 
return input + 1; 
} 
} 
Func addOne = Example.AddOne 
Example.AddOne takes an int and returns an int, its signature matches the delegate Func. 
Example.AddOne can be directly assigned to addOne because they have matching signatures. 
 

0 Comment's

Comment Form