Why does the IEnumerable.Select() works in 1 of 2 cases ? Can not be inferred from usage

后端 未结 5 781
无人及你
无人及你 2021-01-18 03:26

I get this error message:

The type arguments for method \'System.Linq.Enumerable.Select(System.Collections.Generic.IE         


        
5条回答
  •  孤城傲影
    2021-01-18 04:04

    documentsOC.Add returns void.
    It doesn't make any sense (and is impossible) to write .Select(...).

    What you're trying to do cannot work in the first place; Select is lazy and doesn't call your function until you enumerate the results.

    You should use a regular foreach loop.

提交回复
热议问题