Today I got an interesting question, where I have two modes, at a quick glance, both work the same way There is an inimarable of objects.
I have defined them as List 1 and List 2 below:
Public square fu {Public Ent ID { get receive; Set; } Enable Public Buttons {get; Set;}} Public Static Class Data {Public Fixed IEnumerable & lt; Foo & gt; List 1 {Get Return New List & lt; Foo & gt; {New fu {id = 1, enabled = true}, new fu {id = 2, enabled = true}, new fu {id = 3, capable = true}}; }} Public stable IEnumerable & lt; Foo & gt; List 2 {Get {Return New Foo} ID = 1, Enable = True}; Returns new fu {id = 2, enabled = true}; Returns new fu {id = 3, enabled = true}; }}}
Now consider the following tests:
IEnumerable & lt; Foo & gt; Liston = data.list 1; List One Where (object => item.id.qual (2)). first (). Capable = false; Assurance First (wrong, list a. (1) enabled.); Decide. Indefinite (false, list for a list.) [1]. Enabled); IEnumerable & LT; Foo & gt; List Two = DataList 2; List two. Where (item => item.id device (2)). first (). Capable = false; Decide. First (wrong, list two. Element (1). Enabled); Responsibility Uncertain (false, list two.To-list () [1]. Enabled);
These two methods start doing "one thing"
Why the second claim in the test code fail?
Why the second "Foo" item of two is not set on the lie when it is on the list?
Note: I am after the explanation of why this is allowed to happen and how is the difference between the two, how to fix the other claim, as if I know that if I have a ToList If I add a call then this will work.
Creates an item once the first block of code and returns a list with items.
The second block of code creates those items every time that is run through IEnumerable.
This means that the second and third lines of the first block work on the same object example. The second and third lines of the second block work on Foo's different examples (new instances are created as you do it).
The best way to see this is to set breakpoints and run this code under the debugger methods. The first version will hit the breakpoint only once. Once during the second edition, it will hit twice. Where to call (), and during one time (Edit: The breakpoint will also be hit for the third time during this toolt call) along with the modified code.
The thing to remember here is that the use of an iterative method (i.e. yield yield When the calculator is turned on through every time, not only the initial return value is created.
Comments
Post a Comment