30.06.2013 Views

Book of Red Gate 2010 - Red Gate Software

Book of Red Gate 2010 - Red Gate Software

Book of Red Gate 2010 - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4. Fill in the … to make this valid<br />

… x = Part1();<br />

Part2(x);<br />

5. I wrote this bit <strong>of</strong> code but before I got to run it, my<br />

friend refactored it. Was my version better?<br />

My version<br />

var results = new List();<br />

for (int i = 0; i < 5; i++)<br />

{<br />

}<br />

var j = 2*i;<br />

results.Add(() => j);<br />

results.ForEach(x => Console.<br />

WriteLine(x()));<br />

His version<br />

var results = new List();<br />

for (int i = 0; i < 5; i++)<br />

{<br />

results.Add(() => 2 * i);<br />

}<br />

results.ForEach(x => Console.<br />

WriteLine(x()));<br />

103

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!