Skip to main content
6 events
when toggle format what by license comment
Aug 19, 2014 at 14:28 comment added Martin Braun This is right, they are not copies, furthermore they are new objects, indeed. Also by saying collection I was referencing to objects you can count through (objects that hold more than one object in a any kind of array), not to classes that inherit from ICollection. My bad.
Aug 19, 2014 at 14:20 comment added Telastyn @modix - They return new objects that implement IEnumerable, but to be clear, they are not copies, and they are not collections (except for ToList, ToArray, etc.) .
Aug 19, 2014 at 14:17 comment added Martin Braun Why I can do obj = myCollection.Where(x => x.MyProperty > 0).OrderBy(x => x.MyProperty); then? Where() returns a new collection object. OrderBy() even returns a different collection object, because the content is ordered.
Aug 19, 2014 at 14:11 comment added Telastyn @modix - LINQ does not return a copy while appending operations.
Aug 19, 2014 at 14:08 comment added Martin Braun Thx for your answer. I'm mainly working with the .NET framework, and by your answer it's full of non-idiomatic things. While things like LINQ methods return a new copy of the original after appending operations etc. things like the Clear() or Add() of any collection type will modify the same instance and return void. In both cases you say it would be confusing...
Aug 19, 2014 at 13:40 history answered Telastyn CC BY-SA 3.0