Indexers, Operators, and
Pointers
I
n this chapter, you’ll deepen your understanding of the C# programming language by examining
a handful of advanced syntactic constructs. To begin, you’ll learn how to construct and use an
indexer method. This C# mechanism enables you to build custom types that provide access to inter-
nal subtypes using an array-like syntax. Once you learn how to build an indexer method, you’ll then
examine how to overload various operators (+, -, <, >, and so forth), and how to create custom
explicit and implicit conversion routines for your types (and you’ll learn why you may wish to
do so).
The remainder of this chapter examines a small set of lesser used (but nonetheless interesting)
C# keywords. For example, you’ll learn how to create an “unsafe” code context in order to directly
manipulate pointer types using C# and make use of various preprocessor directives.
Do'stlaringiz bilan baham: