最佳答案
在 C # 中是否有与 F # 的 List.map 函数等价的函数?例如,对列表中的每个元素应用一个函数,并返回一个包含结果的新列表。
比如:
public static IEnumerable<TResult> Map<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> funky)
{
foreach (TSource element in source)
yield return funky.Invoke(element);
}
是否已经有一个内置的方式或者我应该只写自定义扩展?