C# : how to use delegate Func

4/1/2014·1 min read

C# provide Func to support delegate.

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

define method and callpublic void Test()
{
Func<intbool> _getResult = delegate(int _in) 

return (_in == 0); 
}; 
Func<booldecimal> _getValue = ( bool _invalue) => 

return _invalue.GetHashCode(); 
}; 
bool result = _getResult(3); 
decimal number = _getValue.Invoke(true);
}