delegate as parameter
In this chapter you will learn:
Use delegate as the function parameter
using System;//from ja v a2 s.c o m
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
delegate void FooBar();
public class MainClass
{
static void Invoke3Times(FooBar d)
{
d(); d(); d();
}
public static void Main(){
int i = 0;
Invoke3Times(delegate { i++; });
Console.WriteLine(i);
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » delegate, lambda, event