LINQ - Does the Where expression return new instance or reference to object instance

后端 未结 5 1804
自闭症患者
自闭症患者 2021-01-31 15:01

This is probably a basic question for some, but it affects how I design a piece of my program.

I have a single collection of type A:

IEnumerable         


        
5条回答
  •  孤城傲影
    2021-01-31 15:14

    Making a new object that is a reference type is non-trivial. LINQ would have no idea how to do it. LINQ always returns the same instances when dealing with reference types.

提交回复
热议问题