13.07.2015 Views

C# in Depth

C# in Depth

C# in Depth

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Parameterizedtyp<strong>in</strong>g with genericsThis chapter covers■Generic types and methods■ Generic collections <strong>in</strong> .NET 2.0■■Limitations of genericsComparisons with other languagesTrue 1 story: the other day my wife and I did our weekly grocery shopp<strong>in</strong>g. Justbefore we left, she asked me if I had the list. I confirmed that <strong>in</strong>deed I did have thelist, and off we went. It was only when we got to the grocery store that our mistakemade itself obvious. My wife had been ask<strong>in</strong>g about the shopp<strong>in</strong>g list whereas I’dactually brought the list of neat features <strong>in</strong> <strong>C#</strong> 2. When we asked an assistantwhether we could buy any anonymous methods, we received a very strange look.If only we could have expressed ourselves more clearly! If only she’d had someway of say<strong>in</strong>g that she wanted me to br<strong>in</strong>g the list of items we wanted to buy! If onlywe’d had generics…1By which I mean “convenient for the purposes of <strong>in</strong>troduc<strong>in</strong>g the chapter”—not, you know, accurate as such.63Licensed to Rhona Hadida

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

Saved successfully!

Ooh no, something went wrong!