3
Answers

Understanding method meaning...

Ask a question
S

S

11y
1.1k
1
Given the following extension\utility\helper method

public static string CommaSeparate<T, U>(this IEnumerable<T> source, Func<T, U> func)
{
return string.Join(",", source.Select(s => func(s).ToString()).ToArray()); }

Im having difficulty in understanding it easily\fully...

My concerns are:-

Why are both T and U needed after CommaSeperate and not just T?

How and why is the Select method mapping to the Func delegate func, by simply s => func(s) ?

Regards
Steve

Answers (3)