Linq: What is the difference between Select and Where

后端 未结 7 834
臣服心动
臣服心动 2020-12-02 07:58

The Select and Where methods are available in Linq. What should every developer know about these two methods? For example: when to use one over th

相关标签:
7条回答
  • 2020-12-02 08:56

    In case of Select it you can map to an IEnumerable of a new structure.

      A.Select(x=>new X{UID=x.uid, UNAME=x.uname}) 
      //input as [IEnumerable<A>] -------->  return output as [IEnumerable<X> ]
    

    Where() works as an filter to the IEnumerable, it will return the result on the basis of the where clause.

    A.Where(x=>x.uid!=0) //input as [IEnumerable<A>] -------->  return output as [IEnumerable<A> ]
    
    0 讨论(0)
提交回复
热议问题