Alex Rivera | Logout

What's the difference between Func<T, TResult> and Converter<TInput, TOutput>?

Asked 2009-06-03T10:03:33.687
10

Looking at the signatures for the Func and Converter delegates,

public delegate TResult Func<T, TResult>(T arg);
public delegate TOutput Converter<TInput, TOutput>(TInput input);

I'm struggling to see the difference between the two. Surely, if we rename the generic type arguments, they essentially amount to the same thing?

Can anyone explain why they both exist, please?

Edit
Report

1 Answer

18

There is no difference. The reason for their existence is historical. Converter<T1,T2> was already available in .NET 2.0, but a whole range of Func<> delegate types were added later on. For consistency, Func<T,TResult> was added, but it did the same thing as Converter<T1,T2>.

answered 2009-06-03T10:06:46.533

Your Answer