With great surprises, I observed the following behavior today: Given a square
class Support Foo {Intel FUNNumber {Receive; Set; }} and this code
IEnumerable & lt; Foo & gt; Foos = Ungrammable. Ranges (0,3). Select (new foo ()); Furch (Foo in Fayos) foo.Bar = 5; Fourte (Wire Foo In Fooze) Console White (foo.Bar); New list & lt; Foo & gt; "New" (Foo), new Foo (), creates "code 555" for writing new "foo" ("f5"). My question: Why does this happen and deny using this method as .oList () is a comment because it is not required).
This is because foos dynamically every time you call it Calculate, therefore, during the first run, you are setting property values on objects, which are not referenced after the end of the run, the second trend works on freshly constructed objects, which have the default asset value. Things change by starting fuses in the list of "continuous" objects, such as .toList () the only reason (creating a "fixed" list And is repeated more than twice; the original is dynamically created IEnumerable is performed more than once more). Installed that you should use the .toList () : in general I do not think it's needed because of a comment It is not customizable to iterate more than once dynamically created sequences (I believe many code analysis tools warn against this), but write each one in every way.
Comments
Post a Comment