Collections, Comparisons, and Conversions

Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid · 2018

This chapter discusses some more advanced techniques available in C#: collections; comparisons; and conversions. Collections enable the users to maintain groups of objects. Collections can include more advanced functionality, such as controlling access to the objects they contain, searching and sorting, and more. The chapter first explains how to use and create collection classes and talks about some powerful techniques for getting the most out of them. When dealing with objects, the users often want to make comparisons between them. This is especially important in collections, because it is how sorting is achieved. The chapter then looks at how to compare objects in a number of ways, including operator overloading, and how to use the IComparable and IComparer interface to sort collections. Finally, it explores how to customize type conversions to suit the users' needs.

Read the paper · More papers on PaperTik