C# : how to use delegate Action

4/1/2014·1 min read

C# provide Action to support delegate.

Action unlike Func, it's not able to return result.

define method and callpublic void Test()
{
Action<int > check = delegate(int _number) 

if (_number == 3) { 
Console.Write("yes"); 
return (_in == 0); 
}; 
List<int> list = new List<int> { 1, 2, 3, 4, 5, 6 }; 
list.ForEach(check); 
}