■ Contents
xix
Understanding Custom Type Conversions .................................................................... 419
Recall: Numerical Conversions ........................................................................................................... 419
Recall: Conversions Among Related Class Types ................................................................................ 419
Creating Custom Conversion Routines ...............................................................................................420
Additional Explicit Conversions for the Square Type........................................................................... 423
Defining Implicit Conversion Routines ................................................................................................ 424
Understanding Extension Methods ............................................................................... 425
Defining Extension Methods ............................................................................................................... 426
Invoking Extension Methods ............................................................................................................... 427
Importing Extension Methods ............................................................................................................. 428
The IntelliSense of Extension Methods ............................................................................................... 428
Extending Types Implementing Specific Interfaces ............................................................................ 429
Understanding Anonymous Types ................................................................................ 431
Defining an Anonymous Type .............................................................................................................. 431
The Internal Representation of Anonymous Types .............................................................................. 432
The Implementation of ToString() and GetHashCode() ........................................................................ 434
The Semantics of Equality for Anonymous Types ............................................................................... 434
Anonymous Types Containing Anonymous Types ............................................................................... 436
Working with Pointer Types .......................................................................................... 436
The unsafe Keyword ........................................................................................................................... 438
Working with the * and & Operators ................................................................................................... 440
An Unsafe (and Safe) Swap Function .................................................................................................441
Field Access via Pointers (the -> Operator) ........................................................................................ 442
The stackalloc Keyword ......................................................................................................................442
Pinning a Type via the fixed Keyword ................................................................................................. 443
The sizeof Keyword ............................................................................................................................444
Summary ...................................................................................................................... 444
■Chapter 12: LINQ to Objects ������������������������������������������������������������������������������� 445
LINQ-Specific Programming Constructs ....................................................................... 445
Implicit Typing of Local Variables ....................................................................................................... 446
Object and Collection Initialization Syntax.......................................................................................... 446