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

后端 未结 5 782
无人及你
无人及你 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 03:51

    What is the return type of ObservableCollection.Add? Typically an Add method returns void. You can't use LINQ Select to execute a procedure for all elements, only a function that returns something (else where would the return value of Select come from?). Instead you can use LINQ ForEach or the C# foreach loop.

提交回复
热议问题