Anonymous Method :
We have seen a delegate now it's time to know about Anonymous Method. So we can create a delegate instance without using method name.
Example :
We have seen a delegate now it's time to know about Anonymous Method. So we can create a delegate instance without using method name.
Example :
class Program
{
public delegate int OperationDelegate(int a, int b);
static void Main(string[] args)
{
OperationDelegate addOperation = delegate(int a, int b)
{
return a + b;
};
Console.WriteLine(addOperation(10, 20));
Console.Read();
}
}
Explanation:
We have put a method inside a block. which is anonymous method.
We have put a method inside a block. which is anonymous method.
No comments:
Post a Comment