Explain introductory timing of Action<T> versus Func<T,TResult> Delegates
Why was Func<T, TResult>(开发者_如何学C..) introduced with .NET 3.0 whereas Action<T>(..) with .NET 2.0?
Edit: I'm coding a project in .NET 2.0 right now and am missing Func. Although it's easy to roll your own as mentioned in the comments and answers i.e. simple delegate TResult Func<T,TResult>(T);
I am curious why the timing would be different with two items so similar in nature.
Action<T>
and Predicate<T>
were probably added because of the methods on List<T>
. It wasn't until C# 3.5 that lambdas were introduced and general delegates like these were particularly convenient.
But as John mentioned, just create your own. There's nothing special about those delegates.
精彩评论