Guest User

Guest User

  • Tech Writer
  • 357
  • 121.1k

Understanding method meaning...

Jan 9 2013 4:24 PM
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)