Cover image for C# 3.0 in a Nutshell, 3rd Edition

Book description

This is a concise yet thorough reference to C# 3.0 programming as implemented in Microsoft's Visual Studio 2008. C# 3.0 in a Nutshell gets right to the point, covering the essentials of language syntax and usage as well as the parts of the .NET base class libraries you need to build working applications. But unlike earlier editions, this book is now organized entirely around concepts and use cases, providing greater depth and readability. C# 3.0 introduces the most significant enhancements yet to the programming language, and C# 3.0 in a Nutshell delves deep into the subject while assuming minimal prior knowledge of C#-making it accessible to anyone with a reasonable background in programming. In addition to the language, the book covers the .NET CLR and the core Framework assemblies, along with the unified querying syntax called Language Integrated Query (LINQ), which bridges the traditional divide between programs and their data sources. Free of clutter and long introductions, this book provides a map of C# 3.0 knowledge in a succinct and unified style:

  • Opening chapters concentrate purely on C#, starting with the basics of syntax, types and variables, and finishing with advanced topics such as unsafe code and preprocessor directives

  • Later chapters cover the core .NET 3.5 Framework, including such topics as LINQ, XML, collections, I/O and networking, memory management, reflection, attributes, security, threading, application domains and native interoperability

Designed as a handbook for daily use, C# 3.0 in a Nutshell is an ideal companion to any of the vast array of books that focus on an applied technology such as WPF, ASP.NET, or WCF. The areas of the language and .NET Framework that such books omit, this one covers in detail.

Table of Contents

  1. C# 3.0 in a Nutshell, 3rd Edition
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Intended Audience
    2. How This Book Is Organized
    3. What You Need to Use This Book
    4. Conventions Used in This Book
    5. Using Code Examples
    6. We'd Like to Hear from You
    7. Safari® Books Online
    8. Acknowledgments
      1. Joseph Albahari
      2. Ben Albahari
  4. 1. Introducing C# and the .NET Framework
    1. 1.1. Object Orientation
    2. 1.2. Type Safety
    3. 1.3. Memory Management
    4. 1.4. Platform Support
    5. 1.5. C#'s Relationship with the CLR
    6. 1.6. The CLR and .NET Framework
    7. 1.7. What's New in C# 3.0
  5. 2. C# Language Basics
    1. 2.1. A First C# Program
      1. 2.1.1. Compilation
    2. 2.2. Syntax
      1. 2.2.1. Identifiers and Keywords
        1. 2.2.1.1. Avoiding conflicts
        2. 2.2.1.2. Contextual keywords
      2. 2.2.2. Literals, Punctuators, and Operators
      3. 2.2.3. Comments
    3. 2.3. Type Basics
      1. 2.3.1. Predefined Type Examples
      2. 2.3.2. Custom Type Examples
        1. 2.3.2.1. Members of a type
        2. 2.3.2.2. Symmetry of predefined types and custom types
        3. 2.3.2.3. Constructors and instantiation
        4. 2.3.2.4. Instance versus static members
        5. 2.3.2.5. The public keyword
      3. 2.3.3. Conversions
      4. 2.3.4. Value Types Versus Reference Types
        1. 2.3.4.1. Value types
        2. 2.3.4.2. Reference types
        3. 2.3.4.3. Null
        4. 2.3.4.4. Storage overhead
      5. 2.3.5. Predefined Type Taxonomy
    4. 2.4. Numeric Types
      1. 2.4.1. Numeric Literals
        1. 2.4.1.1. Numeric literal type inference
        2. 2.4.1.2. Numeric suffixes
      2. 2.4.2. Numeric Conversions
        1. 2.4.2.1. Integral to integral conversions
        2. 2.4.2.2. Floating-point to floating-point conversions
        3. 2.4.2.3. Floating-point to integral conversions
        4. 2.4.2.4. Decimal conversions
      3. 2.4.3. Arithmetic Operators
      4. 2.4.4. Increment and Decrement Operators
      5. 2.4.5. Specialized Integral Operations
        1. 2.4.5.1. Integral division
        2. 2.4.5.2. Integral overflow
        3. 2.4.5.3. Integral arithmetic overflow check operators
        4. 2.4.5.4. Overflow checking for constant expressions
        5. 2.4.5.5. Bitwise operators
      6. 2.4.6. Eight- and 16-Bit Integrals
      7. 2.4.7. Special Float and Double Values
      8. 2.4.8. double Versus decimal
      9. 2.4.9. Real Number Rounding Errors
    5. 2.5. Boolean Type and Operators
      1. 2.5.1. Bool Conversions
      2. 2.5.2. Equality and Comparison Operators
      3. 2.5.3. Conditional Operators
    6. 2.6. Strings and Characters
      1. 2.6.1. Char conversions
      2. 2.6.2. String Type
        1. 2.6.2.1. String concatenation
        2. 2.6.2.2. String comparisons
    7. 2.7. Arrays
      1. 2.7.1. Default Element Initialization
        1. 2.7.1.1. Value types versus reference types
      2. 2.7.2. Multidimensional Arrays
        1. 2.7.2.1. Rectangular arrays
        2. 2.7.2.2. Jagged arrays
      3. 2.7.3. Simplified Array Initialization Expressions
      4. 2.7.4. Bounds Checking
    8. 2.8. Variables and Parameters
      1. 2.8.1. The Stack and the Heap
        1. 2.8.1.1. Stack
        2. 2.8.1.2. Heap
      2. 2.8.2. Definite Assignment
      3. 2.8.3. Default Values
      4. 2.8.4. Parameters
        1. 2.8.4.1. Passing arguments by value
        2. 2.8.4.2. The ref modifier
        3. 2.8.4.3. The out modifier
        4. 2.8.4.4. Implications of passing by reference
        5. 2.8.4.5. The params modifier
      5. 2.8.5. var—Implicitly Typed Local Variables (C# 3.0)
    9. 2.9. Expressions and Operators
      1. 2.9.1. Primary Expressions
      2. 2.9.2. Void Expressions
      3. 2.9.3. Assignment Expressions
      4. 2.9.4. Operator Precedence and Associativity
        1. 2.9.4.1. Precedence
        2. 2.9.4.2. Left-associative operators
        3. 2.9.4.3. Right-associative operators
      5. 2.9.5. Operator Table
    10. 2.10. Statements
      1. 2.10.1. Declaration Statements
        1. 2.10.1.1. Local variables
      2. 2.10.2. Expression Statements
      3. 2.10.3. Selection Statements
        1. 2.10.3.1. The if statement
        2. 2.10.3.2. The else clause
        3. 2.10.3.3. Changing the flow of execution with braces
        4. 2.10.3.4. The switch statement
      4. 2.10.4. Iteration Statements
        1. 2.10.4.1. while and do-while loops
        2. 2.10.4.2. for loops
        3. 2.10.4.3. foreach loops
      5. 2.10.5. Jump Statements
        1. 2.10.5.1. The break statement
        2. 2.10.5.2. The continue statement
        3. 2.10.5.3. The goto statement
        4. 2.10.5.4. The return statement
        5. 2.10.5.5. The throw statement
      6. 2.10.6. Miscellaneous Statements
    11. 2.11. Namespaces
      1. 2.11.1. The namespace Keyword
      2. 2.11.2. Fully Qualified Names
      3. 2.11.3. The using Directive
      4. 2.11.4. The Global Namespace
      5. 2.11.5. Rules Within a Namespace
        1. 2.11.5.1. Name scoping
        2. 2.11.5.2. Name hiding
        3. 2.11.5.3. Repeated namespaces
        4. 2.11.5.4. Nested using directive
      6. 2.11.6. Aliasing Types and Namespaces
      7. 2.11.7. Advanced Namespace Features
        1. 2.11.7.1. Extern
        2. 2.11.7.2. Namespace alias qualifiers
  6. 3. Creating Types in C#
    1. 3.1. Classes
      1. 3.1.1. Fields
        1. 3.1.1.1. The readonly modifier
        2. 3.1.1.2. Field initialization
        3. 3.1.1.3. Declaring multiple fields together
      2. 3.1.2. Methods
        1. 3.1.2.1. Overloading methods
        2. 3.1.2.2. Pass-by-value versus pass-by-reference
      3. 3.1.3. Instance Constructors
        1. 3.1.3.1. Overloading constructors
        2. 3.1.3.2. Implicit parameterless constructors
        3. 3.1.3.3. Constructor and field initialization order
        4. 3.1.3.4. Nonpublic constructors
      4. 3.1.4. Object Initializers (C# 3.0)
      5. 3.1.5. The this Reference
      6. 3.1.6. Properties
        1. 3.1.6.1. Read-only and calculated properties
        2. 3.1.6.2. Automatic properties (C# 3.0)
        3. 3.1.6.3. get and set accessibility
        4. 3.1.6.4. CLR property implementation
      7. 3.1.7. Indexers
        1. 3.1.7.1. Implementing an indexer
        2. 3.1.7.2. CLR indexer implementation
      8. 3.1.8. Constants
      9. 3.1.9. Static Constructors
        1. 3.1.9.1. Static field initialization order
        2. 3.1.9.2. Nondeterminism of static constructors
      10. 3.1.10. Static Classes
      11. 3.1.11. Finalizers
      12. 3.1.12. Partial Types and Methods
        1. 3.1.12.1. Partial methods (C# 3.0)
    2. 3.2. Inheritance
      1. 3.2.1. Polymorphism
      2. 3.2.2. Casting
        1. 3.2.2.1. Upcasting
        2. 3.2.2.2. Downcasting
        3. 3.2.2.3. The as operator
        4. 3.2.2.4. The is operator
      3. 3.2.3. Virtual Function Members
      4. 3.2.4. Abstract Classes and Abstract Members
      5. 3.2.5. Hiding Inherited Members
        1. 3.2.5.1. new versus virtual
      6. 3.2.6. Sealing Functions and Classes
      7. 3.2.7. The base Keyword
      8. 3.2.8. Constructors and Inheritance
        1. 3.2.8.1. Implicit calling of the parameterless base class constructor
        2. 3.2.8.2. Constructor and field initialization order
      9. 3.2.9. Overloading and Resolution
    3. 3.3. The object Type
      1. 3.3.1. Boxing and Unboxing
        1. 3.3.1.1. Copying semantics of boxing and unboxing
      2. 3.3.2. Static and Dynamic Type Checking
      3. 3.3.3. The GetType Method and typeof Operator
      4. 3.3.4. The ToString Method
      5. 3.3.5. Object Member Listing
    4. 3.4. Structs
      1. 3.4.1. Struct Construction Semantics
    5. 3.5. Access Modifiers
      1. 3.5.1. Examples
      2. 3.5.2. Accessibility Capping
      3. 3.5.3. Restrictions on Access Modifiers
    6. 3.6. Interfaces
      1. 3.6.1. Extending an Interface
      2. 3.6.2. Explicit Interface Implementation
      3. 3.6.3. Implementing Interface Members Virtually
      4. 3.6.4. Reimplementing an Interface in a Subclass
        1. 3.6.4.1. Alternatives to interface reimplementation
      5. 3.6.5. Interfaces and Boxing
      6. 3.6.6. Writing a Class Versus an Interface
    7. 3.7. Enums
      1. 3.7.1. Enum Conversions
      2. 3.7.2. Flags Enumerations
      3. 3.7.3. Enum Operators
      4. 3.7.4. Type-Safety Issues
    8. 3.8. Nested Types
    9. 3.9. Generics
      1. 3.9.1. Generic Types
      2. 3.9.2. Why Generics Exist
      3. 3.9.3. Generic Methods
      4. 3.9.4. Declaring Generic Parameters
      5. 3.9.5. typeof and Generics
      6. 3.9.6. The default Generic Value
      7. 3.9.7. Generic Constraints
      8. 3.9.8. Generics and Covariance
        1. 3.9.8.. A comparison of generic types and array types
      9. 3.9.9. Subclassing Generic Types
      10. 3.9.10. Self-Referencing Generic Declarations
      11. 3.9.11. Static Data
      12. 3.9.12. C# Generics Versus C++ Templates
  7. 4. Advanced C#
    1. 4.1. Delegates
      1. 4.1.1. Writing Plug-in Methods with Delegates
      2. 4.1.2. Multicast Delegates
        1. 4.1.2.1. Multicast delegate example
      3. 4.1.3. Instance Method Targets
      4. 4.1.4. Generic Delegate Types
      5. 4.1.5. Delegates Versus Interfaces
      6. 4.1.6. Delegate Compatibility
        1. 4.1.6.1. Type compatibility
        2. 4.1.6.2. Parameter compatibility
        3. 4.1.6.3. Return type compatibility
    2. 4.2. Events
      1. 4.2.1. Standard Event Pattern
      2. 4.2.2. Event Accessors
      3. 4.2.3. Event Modifiers
    3. 4.3. Lambda Expressions (C# 3.0)
      1. 4.3.1. Explicitly Specifying Lambda Parameter Types
      2. 4.3.2. Generic Lambda Expressions and the Func Delegates
      3. 4.3.3. Outer Variables
    4. 4.4. Anonymous Methods
    5. 4.5. try Statements and Exceptions
      1. 4.5.1. The catch Clause
      2. 4.5.2. The finally Block
        1. 4.5.2.1. The using statement
      3. 4.5.3. Throwing Exceptions
        1. 4.5.3.1. Rethrowing an exception
      4. 4.5.4. Key Properties of System.Exception
      5. 4.5.5. Common Exception Types
      6. 4.5.6. Common Patterns
        1. 4.5.6.1. The try method pattern
        2. 4.5.6.2. The atomicity pattern
        3. 4.5.6.3. Alternatives to exceptions
    6. 4.6. Enumeration and Iterators
      1. 4.6.1. Enumeration
      2. 4.6.2. Iterators
      3. 4.6.3. Iterator Semantics
      4. 4.6.4. Composing Sequences
      5. 4.6.5. Collection Initializers
    7. 4.7. Nullable Types
      1. 4.7.1. Null Basics
        1. 4.7.1.1. Nullable<T> struct
        2. 4.7.1.2. Implicit and explicit nullable conversions
        3. 4.7.1.3. Boxing and unboxing nullable values
      2. 4.7.2. Lifted Operators
        1. 4.7.2.1. Equality operators (== !=)
        2. 4.7.2.2. Relational operators (< <= >= >)
        3. 4.7.2.3. All other operators (+ − * / % & | ^ << >> + ++ − -- ! ∼)
        4. 4.7.2.4. Mixing nullable and nonnullable operators
      3. 4.7.3. bool?
      4. 4.7.4. Null Coalescing Operator
      5. 4.7.5. Scenarios for Nullable Types
      6. 4.7.6. Alternatives to Nullable Types
    8. 4.8. Operator Overloading
      1. 4.8.1. Overview
      2. 4.8.2. Operator Functions
      3. 4.8.3. Overloading Equality and Comparison Operators
      4. 4.8.4. Custom Implicit and Explicit Conversions
      5. 4.8.5. Overloading true and false
    9. 4.9. Extension Methods (C# 3.0)
      1. 4.9.1. Extension Method Chaining
      2. 4.9.2. Ambiguity and Resolution
        1. 4.9.2.1. Namespaces
        2. 4.9.2.2. Extension methods versus instance methods
        3. 4.9.2.3. Extension methods versus extension methods
      3. 4.9.3. Extension Methods on Interfaces
    10. 4.10. Anonymous Types (C# 3.0)
    11. 4.11. Attributes
      1. 4.11.1. Attribute Classes
      2. 4.11.2. Named and Positional Parameters
      3. 4.11.3. Attribute Targets
      4. 4.11.4. Specifying Multiple Attributes
    12. 4.12. Unsafe Code and Pointers
      1. 4.12.1. Pointer Basics
      2. 4.12.2. Unsafe Code
      3. 4.12.3. The fixed Statement
      4. 4.12.4. The Pointer-to-Member Operator
      5. 4.12.5. Arrays
        1. 4.12.5.1. The stackalloc keyword
        2. 4.12.5.2. Fixed-size buffers
      6. 4.12.6. void*
      7. 4.12.7. Pointers to Unmanaged Code
    13. 4.13. Preprocessor Directives
      1. 4.13.1. Conditional Attributes
      2. 4.13.2. Pragma Warning
    14. 4.14. XML Documentation
      1. 4.14.1. Predefined XML Tags
      2. 4.14.2. User-Defined Tags
      3. 4.14.3. Type or Member Cross-References
  8. 5. Framework Overview
    1. 5.1. The CLR and Core Framework
      1. 5.1.1. System Types
      2. 5.1.2. Text Processing
      3. 5.1.3. Collections
      4. 5.1.4. Queries
      5. 5.1.5. XML
      6. 5.1.6. Streams and I/O
      7. 5.1.7. Networking
      8. 5.1.8. Serialization
      9. 5.1.9. Assemblies, Reflection, and Attributes
      10. 5.1.10. Security
      11. 5.1.11. Threading and Asynchronous Methods
      12. 5.1.12. Application Domains
      13. 5.1.13. Native Interoperability
      14. 5.1.14. Diagnostics
    2. 5.2. Applied Technologies
      1. 5.2.1. User Interface Technologies
        1. 5.2.1.1. ASP.NET
        2. 5.2.1.2. Windows Presentation Foundation (WPF)
        3. 5.2.1.3. Windows Forms
      2. 5.2.2. Backend Technologies
        1. 5.2.2.1. ADO.NET
        2. 5.2.2.2. Windows Workflow
        3. 5.2.2.3. COM+ and MSMQ
      3. 5.2.3. Distributed System Technologies
        1. 5.2.3.1. Windows Communication Foundation (WCF)
        2. 5.2.3.2. Remoting and Web Services
        3. 5.2.3.3. CardSpace
  9. 6. Framework Fundamentals
    1. 6.1. String and Text Handling
      1. 6.1.1. char
      2. 6.1.2. String
        1. 6.1.2.1. Constructing strings
        2. 6.1.2.2. Null and empty strings
        3. 6.1.2.3. Accessing characters within a string
        4. 6.1.2.4. Searching within strings
        5. 6.1.2.5. Manipulating strings
        6. 6.1.2.6. Splitting and joining strings
        7. 6.1.2.7. String.Format and composite format strings
      3. 6.1.3. Comparing Strings
        1. 6.1.3.1. Ordinal versus culture comparison
        2. 6.1.3.2. Equality comparison
        3. 6.1.3.3. Order comparison
      4. 6.1.4. StringBuilder
      5. 6.1.5. Text Encodings and Unicode
        1. 6.1.5.1. Obtaining an Encoding object
        2. 6.1.5.2. Encoding for file and stream I/O
        3. 6.1.5.3. Encoding to byte arrays
        4. 6.1.5.4. UTF-16 and strings
    2. 6.2. Dates and Times
      1. 6.2.1. TimeSpan
      2. 6.2.2. DateTime and DateTimeOffset
        1. 6.2.2.1. Choosing between DateTime and DateTimeOffset
        2. 6.2.2.2. Constructing a DateTime
        3. 6.2.2.3. Constructing a DateTimeOffset
        4. 6.2.2.4. The current DateTime/DateTimeOffset
        5. 6.2.2.5. Working with dates and times
        6. 6.2.2.6. Formatting and parsing
        7. 6.2.2.7. Null DateTime and DateTimeOffset values
    3. 6.3. Dates and Time Zones
      1. 6.3.1. DateTime and Time Zones
      2. 6.3.2. DateTimeOffset and Time Zones
      3. 6.3.3. TimeZone and TimeZoneInfo
        1. 6.3.3.1. TimeZone
        2. 6.3.3.2. TimeZoneInfo
      4. 6.3.4. Daylight Saving and DateTime
    4. 6.4. Formatting and Parsing
      1. 6.4.1. ToString and Parse
      2. 6.4.2. Format Providers
        1. 6.4.2.1. Format providers and CultureInfo
        2. 6.4.2.2. Using NumberFormatInfo or DateTimeFormatInfo
        3. 6.4.2.3. Composite formatting
        4. 6.4.2.4. Parsing with format providers
        5. 6.4.2.5. IFormatProvider and ICustomFormatter
    5. 6.5. Standard Format Strings and Parsing Flags
      1. 6.5.1. Numeric Format Strings
      2. 6.5.2. NumberStyles
      3. 6.5.3. DateTime Format Strings
        1. 6.5.3.1. Parsing and misparsing DateTimes
      4. 6.5.4. DateTimeStyles
      5. 6.5.5. Enum Format Strings
    6. 6.6. Other Conversion Mechanisms
      1. 6.6.1. Convert
        1. 6.6.1.1. Rounding real to integral conversions
        2. 6.6.1.2. Parsing numbers in base 2, 8, and 16
        3. 6.6.1.3. Dynamic conversions
        4. 6.6.1.4. Base 64 conversions
      2. 6.6.2. XmlConvert
      3. 6.6.3. Type Converters
      4. 6.6.4. BitConverter
    7. 6.7. Working with Numbers
      1. 6.7.1. Conversions
      2. 6.7.2. Math
      3. 6.7.3. Random
    8. 6.8. Enums
      1. 6.8.1. Enum Conversions
        1. 6.8.1.1. enum to integral conversions
        2. 6.8.1.2. Integral to enum conversions
        3. 6.8.1.3. String conversions
      2. 6.8.2. Enumerating Enum Values
      3. 6.8.3. How Enums Work
    9. 6.9. The Guid Struct
    10. 6.10. Equality Comparison
      1. 6.10.1. Referential Versus Value Equality
      2. 6.10.2. Standard Equality Protocols
        1. 6.10.2.1. == and !=
        2. 6.10.2.2. The virtual Object.Equals method
        3. 6.10.2.3. The static object.Equals method
        4. 6.10.2.4. The static object.ReferenceEquals method
        5. 6.10.2.5. The IEquatable<T> interface
        6. 6.10.2.6. When Equals and == are not equal
      3. 6.10.3. Equality and Custom Types
        1. 6.10.3.1. How to override equality semantics
        2. 6.10.3.2. Overriding GetHashCode
        3. 6.10.3.3. Overriding Equals
        4. 6.10.3.4. Overloading == and !=
        5. 6.10.3.5. Implementing IEquatable<T>
        6. 6.10.3.6. An example: The Area struct
        7. 6.10.3.7. Pluggable equality comparers
    11. 6.11. Order Comparison
      1. 6.11.1. IComparable
        1. 6.11.1.1. IComparable versus Equals
      2. 6.11.2. < and >
      3. 6.11.3. Implementing the IComparable Interfaces
    12. 6.12. Utility Classes
      1. 6.12.1. Console
      2. 6.12.2. Environment
      3. 6.12.3. Process
  10. 7. Collections
    1. 7.1. Enumeration
      1. 7.1.1. IEnumerable and IEnumerator
      2. 7.1.2. IEnumerable<T> and IEnumerator<T>
      3. 7.1.3. Implementing the Enumeration Interfaces
      4. 7.1.4. IDictionaryEnumerator
    2. 7.2. The ICollection and IList Interfaces
      1. 7.2.1. ICollection and ICollection<T>
      2. 7.2.2. IList and IList<T>
    3. 7.3. The Array Class
      1. 7.3.1. Construction and Indexing
      2. 7.3.2. Enumeration
      3. 7.3.3. Length and Rank
      4. 7.3.4. Searching
      5. 7.3.5. Sorting
      6. 7.3.6. Reversing Elements
      7. 7.3.7. Copying, Converting, and Resizing
    4. 7.4. Lists, Queues, Stacks, and Sets
      1. 7.4.1. List<T> and ArrayList
      2. 7.4.2. LinkedList<T>
      3. 7.4.3. Queue and Queue<T>
      4. 7.4.4. Stack and Stack<T>
      5. 7.4.5. BitArray
      6. 7.4.6. HashSet<T>
    5. 7.5. Dictionaries
      1. 7.5.1. IDictionary and IDictionary<TKey,TValue>
      2. 7.5.2. Dictionary<TKey,TValue> and Hashtable
      3. 7.5.3. OrderedDictionary
      4. 7.5.4. ListDictionary and HybridDictionary
      5. 7.5.5. Sorted Dictionaries
    6. 7.6. Customizable Collections and Proxies
      1. 7.6.1. Collection<T> and CollectionBase
      2. 7.6.2. KeyedCollection<TKey,TItem> and DictionaryBase
      3. 7.6.3. ReadOnlyCollection<T>
    7. 7.7. Plugging in Equality and Order
      1. 7.7.1. IEqualityComparer and EqualityComparer
      2. 7.7.2. IComparer and Comparer
      3. 7.7.3. StringComparer
  11. 8. LINQ Queries
    1. 8.1. Getting Started
    2. 8.2. Lambda Queries
      1. 8.2.1. Chaining Query Operators
        1. 8.2.1.1. Why extension methods are important
      2. 8.2.2. Composing Lambda Expressions
        1. 8.2.2.1. Lambda expressions and Func signatures
        2. 8.2.2.2. Lambda expressions and element typing
      3. 8.2.3. Natural Ordering
      4. 8.2.4. Other Operators
    3. 8.3. Comprehension Queries
      1. 8.3.1. Iteration Variables
      2. 8.3.2. Comprehension Syntax Versus SQL Syntax
      3. 8.3.3. Comprehension Syntax Versus Lambda Syntax
      4. 8.3.4. Mixed Syntax Queries
    4. 8.4. Deferred Execution
      1. 8.4.1. Reevaluation
      2. 8.4.2. Outer Variables
      3. 8.4.3. How Deferred Execution Works
      4. 8.4.4. Chaining Decorators
      5. 8.4.5. How Queries Are Executed
    5. 8.5. Subqueries
      1. 8.5.1. Subqueries and Deferred Execution
    6. 8.6. Composition Strategies
      1. 8.6.1. Progressive Query Building
      2. 8.6.2. The into Keyword
        1. 8.6.2.1. Scoping rules
      3. 8.6.3. Wrapping Queries
    7. 8.7. Projection Strategies
      1. 8.7.1. Object Initializers
      2. 8.7.2. Anonymous Types
      3. 8.7.3. The let Keyword
    8. 8.8. Interpreted Queries
      1. 8.8.1. How Interpreted Queries Work
        1. 8.8.1.1. Execution
      2. 8.8.2. Combining Interpreted and Local Queries
      3. 8.8.3. AsEnumerable
    9. 8.9. LINQ to SQL
      1. 8.9.1. LINQ to SQL Entity Classes
      2. 8.9.2. DataContext
      3. 8.9.3. Automatic Entity Generation
      4. 8.9.4. Associations
      5. 8.9.5. Deferred Execution with LINQ to SQL
      6. 8.9.6. DataLoadOptions
        1. 8.9.6.1. Specifying a filter in advance
        2. 8.9.6.2. Eager loading
      7. 8.9.7. Updates
    10. 8.10. Building Query Expressions
      1. 8.10.1. Delegates Versus Expression Trees
        1. 8.10.1.1. Compiling expression trees
        2. 8.10.1.2. AsQueryable
      2. 8.10.2. Expression Trees
        1. 8.10.2.1. The Expression DOM
  12. 9. LINQ Operators
    1. 9.1. Overview
      1. 9.1.1. Collection → Collection
        1. 9.1.1.1. Filtering
        2. 9.1.1.2. Projecting
        3. 9.1.1.3. Joining
        4. 9.1.1.4. Ordering
        5. 9.1.1.5. Grouping
        6. 9.1.1.6. Set operators
        7. 9.1.1.7. Conversion methods: Import
        8. 9.1.1.8. Conversion methods: Export
      2. 9.1.2. Collection → Noncollection
        1. 9.1.2.1. Element operators
        2. 9.1.2.2. Aggregation methods
        3. 9.1.2.3. Quantifiers
      3. 9.1.3. Noncollection → Collection
        1. 9.1.3.1. Generation methods
    2. 9.2. Filtering
      1. 9.2.1. Where
        1. 9.2.1.1. Comprehension syntax
        2. 9.2.1.2. Enumerable.Where implementation
        3. 9.2.1.3. Overview
        4. 9.2.1.4. Indexed filtering
        5. 9.2.1.5. Where in LINQ to SQL
      2. 9.2.2. Take and Skip
      3. 9.2.3. TakeWhile and SkipWhile
      4. 9.2.4. Distinct
    3. 9.3. Projecting
      1. 9.3.1. Select
        1. 9.3.1.1. Comprehension syntax
        2. 9.3.1.2. Enumerable implementation
        3. 9.3.1.3. Overview
        4. 9.3.1.4. Indexed projection
        5. 9.3.1.5. Select subqueries and object hierarchies
        6. 9.3.1.6. Subqueries and joins in LINQ to SQL
        7. 9.3.1.7. Projecting into concrete types
      2. 9.3.2. SelectMany
        1. 9.3.2.1. Comprehension syntax
        2. 9.3.2.2. Enumerable implementation
        3. 9.3.2.3. Overview
        4. 9.3.2.4. Outer iteration variables
        5. 9.3.2.5. Thinking in comprehension syntax
        6. 9.3.2.6. Joining with SelectMany
        7. 9.3.2.7. SelectMany in LINQ to SQL
        8. 9.3.2.8. Outer joins with SelectMany
    4. 9.4. Joining
      1. 9.4.1. Join and GroupJoin
        1. 9.4.1.1. Join arguments
        2. 9.4.1.2. GroupJoin arguments
        3. 9.4.1.3. Comprehension syntax
        4. 9.4.1.4. Overview
        5. 9.4.1.5. Join
        6. 9.4.1.6. Joining on multiple keys
        7. 9.4.1.7. Joining in lambda syntax
        8. 9.4.1.8. GroupJoin
        9. 9.4.1.9. Flat outer joins
        10. 9.4.1.10. Joining with lookups
        11. 9.4.1.11. Enumerable implementations
    5. 9.5. Ordering
      1. 9.5.1. OrderBy, OrderByDescending, ThenBy, and ThenByDescending
        1. 9.5.1.1. OrderBy and OrderByDescending arguments
        2. 9.5.1.2. ThenBy and ThenByDescending arguments
        3. 9.5.1.3. Comprehension syntax
        4. 9.5.1.4. Overview
        5. 9.5.1.5. Comparers and collations
        6. 9.5.1.6. IOrderedEnumerable and IOrderedQueryable
    6. 9.6. Grouping
      1. 9.6.1. GroupBy
        1. 9.6.1.1. Comprehension syntax
        2. 9.6.1.2. Overview
        3. 9.6.1.3. GroupBy in LINQ to SQL
        4. 9.6.1.4. Grouping by multiple keys
        5. 9.6.1.5. Custom equality comparers
    7. 9.7. Set Operators
      1. 9.7.1. Concat and Union
      2. 9.7.2. Intersect and Except
    8. 9.8. Conversion Methods
      1. 9.8.1. OfType and Cast
      2. 9.8.2. ToArray, ToList, ToDictionary, and ToLookup
      3. 9.8.3. AsEnumerable and AsQueryable
    9. 9.9. Element Operators
      1. 9.9.1. First, Last, and Single
      2. 9.9.2. ElementAt
      3. 9.9.3. DefaultIfEmpty
    10. 9.10. Aggregation Methods
      1. 9.10.1. Count and LongCount
      2. 9.10.2. Min and Max
      3. 9.10.3. Sum and Average
      4. 9.10.4. Aggregate
    11. 9.11. Quantifiers
      1. 9.11.1. Contains and Any
      2. 9.11.2. All and SequenceEqual
    12. 9.12. Generation Methods
      1. 9.12.1. Empty
      2. 9.12.2. Range and Repeat
  13. 10. LINQ to XML
    1. 10.1. Architectural Overview
      1. 10.1.1. What Is a DOM?
      2. 10.1.2. The LINQ to XML DOM
    2. 10.2. X-DOM Overview
      1. 10.2.1. Loading and Parsing
      2. 10.2.2. Saving and Serializing
    3. 10.3. Instantiating an X-DOM
      1. 10.3.1. Functional Construction
      2. 10.3.2. Specifying Content
      3. 10.3.3. Automatic Deep Cloning
    4. 10.4. Navigating and Querying
      1. 10.4.1. Child Node Navigation
        1. 10.4.1.1. FirstNode, LastNode, and Nodes
        2. 10.4.1.2. Retrieving elements
        3. 10.4.1.3. Retrieving a single element
        4. 10.4.1.4. Recursive functions
      2. 10.4.2. Parent Navigation
      3. 10.4.3. Peer Node Navigation
      4. 10.4.4. Attribute Navigation
    5. 10.5. Updating an X-DOM
      1. 10.5.1. Simple Value Updates
      2. 10.5.2. Updating Child Nodes and Attributes
      3. 10.5.3. Updating Through the Parent
        1. 10.5.3.1. Removing a sequence of nodes or attributes
    6. 10.6. Working with Values
      1. 10.6.1. Setting Values
      2. 10.6.2.. Getting Values
      3. 10.6.3. Values and Mixed Content Nodes
      4. 10.6.4. Automatic XText Concatenation
    7. 10.7. Documents and Declarations
      1. 10.7.1. XDocument
      2. 10.7.2. XML Declarations
        1. 10.7.2.1. Writing a declaration to a string
    8. 10.8. Names and Namespaces
      1. 10.8.1. Namespaces in XML
        1. 10.8.1.1. Prefixes
        2. 10.8.1.2. Attributes
      2. 10.8.2. Specifying Namespaces in the X-DOM
      3. 10.8.3. The X-DOM and Default Namespaces
      4. 10.8.4. Prefixes
    9. 10.9. Annotations
    10. 10.10. Projecting into an X-DOM
      1. 10.10.1. Eliminating Empty Elements
      2. 10.10.2. Streaming a Projection
      3. 10.10.3. Transforming an X-DOM
        1. 10.10.3.1. Advanced transformations
  14. 11. Other XML Technologies
    1. 11.1. XmlReader
      1. 11.1.1. Reading Nodes
      2. 11.1.2. Reading Elements
        1. 11.1.2.1. Optional elements
        2. 11.1.2.2. Random element order
        3. 11.1.2.3. Empty elements
        4. 11.1.2.4. Other ReadXXX methods
      3. 11.1.3. Reading Attributes
        1. 11.1.3.1. Attribute nodes
      4. 11.1.4. Namespaces and Prefixes
    2. 11.2. XmlWriter
      1. 11.2.1. Writing Attributes
      2. 11.2.2. Writing Other Node Types
      3. 11.2.3. Namespaces and Prefixes
    3. 11.3. Patterns for Using XmlReader/XmlWriter
      1. 11.3.1. Working with Hierarchical Data
      2. 11.3.2. Mixing XmlReader/XmlWriter with an X-DOM
        1. 11.3.2.1. Using XmlReader with XElement
        2. 11.3.2.2. Using XmlWriter with XElement
    4. 11.4. XmlDocument
      1. 11.4.1. Loading and Saving an XmlDocument
      2. 11.4.2. Traversing an XmlDocument
      3. 11.4.3. InnerText and InnerXml
      4. 11.4.4. Creating and Manipulating Nodes
      5. 11.4.5. Namespaces
    5. 11.5. XPath
      1. 11.5.1. Common XPath Operators
      2. 11.5.2. XPathNavigator
      3. 11.5.3. Querying with Namespaces
      4. 11.5.4. XPathDocument
    6. 11.6. XSD and Schema Validation
      1. 11.6.1. Performing Schema Validation
        1. 11.6.1.1. Validating with an XmlReader
        2. 11.6.1.2. Validating an X-DOM or XmlDocument
    7. 11.7. XSLT
  15. 12. Disposal and Garbage Collection
    1. 12.1. IDisposable, Dispose, and Close
      1. 12.1.1. Standard Disposal Semantics
        1. 12.1.1.1. Close and Stop
      2. 12.1.2. When to Dispose
      3. 12.1.3. Opt-in Disposal
    2. 12.2. Garbage Collection and Finalizers
    3. 12.3. Calling Dispose from a Finalizer
    4. 12.4. How the Garbage Collector Works
      1. 12.4.1. Optimization Techniques
      2. 12.4.2. Forcing Garbage Collection
    5. 12.5. Alternatives to Garbage Collection
  16. 13. Streams and I/O
    1. 13.1. Stream Architecture
    2. 13.2. Using Streams
      1. 13.2.1. Reading and Writing
      2. 13.2.2. Seeking
      3. 13.2.3. Closing and Flushing
      4. 13.2.4. Timeouts
      5. 13.2.5. Thread Safety
      6. 13.2.6. Backing Store Streams
      7. 13.2.7. FileStream
        1. 13.2.7.1. Constructing a FileStream
        2. 13.2.7.2. Specifying a filename
        3. 13.2.7.3. Specifying a FileMode
        4. 13.2.7.4. Advanced FileStream features
      8. 13.2.8. MemoryStream
      9. 13.2.9. PipeStream
        1. 13.2.9.1. Named pipes
        2. 13.2.9.2. Anonymous pipes
      10. 13.2.10. BufferedStream
    3. 13.3. Stream Adapters
      1. 13.3.1. Text Adapters
        1. 13.3.1.1. StreamReader and StreamWriter
        2. 13.3.1.2. Character encodings
        3. 13.3.1.3. StringReader and StringWriter
      2. 13.3.2. Binary Adapters
      3. 13.3.3. Closing and Disposing Stream Adapters
    4. 13.4. File and Directory Operations
      1. 13.4.1. The File Class
        1. 13.4.1.1. Compression and encryption attributes
        2. 13.4.1.2. File security
      2. 13.4.2. The Directory Class
      3. 13.4.3. FileInfo and DirectoryInfo
      4. 13.4.4. Path
      5. 13.4.5. Special Folders
      6. 13.4.6. Querying Volume Information
      7. 13.4.7. Catching Filesystem Events
    5. 13.5. Compression
      1. 13.5.1. Compressing in Memory
    6. 13.6. Isolated Storage
      1. 13.6.1. Isolation Types
      2. 13.6.2. Reading and Writing Isolated Storage
      3. 13.6.3. Store Location
      4. 13.6.4. Enumerating Isolated Storage
  17. 14. Networking
    1. 14.1. Network Architecture
    2. 14.2. Addresses and Ports
    3. 14.3. URIs
    4. 14.4. Request/Response Architecture
      1. 14.4.1. WebClient
      2. 14.4.2. WebRequest and WebResponse
      3. 14.4.3. Proxies
      4. 14.4.4. Authentication
        1. 14.4.4.1. CredentialCache
      5. 14.4.5. Concurrency
      6. 14.4.6. Exception Handling
    5. 14.5. HTTP-Specific Support
      1. 14.5.1. Headers
      2. 14.5.2. Query Strings
      3. 14.5.3. Uploading Form Data
      4. 14.5.4. Cookies
      5. 14.5.5. Forms Authentication
      6. 14.5.6. SSL
    6. 14.6. Writing an HTTP Server
    7. 14.7. Using FTP
    8. 14.8. Using DNS
    9. 14.9. Sending Mail with SmtpClient
    10. 14.10. Using TCP
      1. 14.10.1. Concurrency
    11. 14.11. Receiving POP3 Mail with TCP
  18. 15. Serialization
    1. 15.1. Serialization Concepts
      1. 15.1.1. Serialization Engines
        1. 15.1.1.1. Why three engines?
        2. 15.1.1.2. The data contract serializer
        3. 15.1.1.3. The binary serializer
        4. 15.1.1.4. XmlSerializer
        5. 15.1.1.5. IXmlSerializable
      2. 15.1.2. Formatters
      3. 15.1.3. Explicit Versus Implicit Serialization
    2. 15.2. The Data Contract Serializer
      1. 15.2.1. DataContractSerializer Versus NetDataContractSerializer
      2. 15.2.2. Using the Serializers
        1. 15.2.2.1. Specifying a binary formatter
      3. 15.2.3. Serializing Subclasses
      4. 15.2.4. Object References
        1. 15.2.4.1. Preserving object references
      5. 15.2.5. Version Tolerance
        1. 15.2.5.1. Required members
      6. 15.2.6. Member Ordering
      7. 15.2.7. Null and Empty Values
    3. 15.3. Data Contracts and Collections
      1. 15.3.1. Subclassed Collection Elements
      2. 15.3.2. Customizing Collection and Element Names
    4. 15.4. Extending Data Contracts
      1. 15.4.1. Serialization and Deserialization Hooks
      2. 15.4.2. Interoperating with [Serializable]
      3. 15.4.3. Interoperating with IXmlSerializable
    5. 15.5. The Binary Serializer
      1. 15.5.1. Getting Started
    6. 15.6. Binary Serialization Attributes
      1. 15.6.1. [NonSerialized]
      2. 15.6.2. [OnDeserializing] and [OnDeserialized]
      3. 15.6.3. [OnSerializing] and [OnSerialized]
      4. 15.6.4. [OptionalField] and Versioning
    7. 15.7. Binary Serialization with ISerializable
      1. 15.7.1. Subclassing Serializable Classes
    8. 15.8. XML Serialization
      1. 15. Getting Started with Attribute-Based Serialization
        1. 15.8.1.1. Attributes, names, and namespaces
        2. 15.8.1.2. XML element order
      2. 15.8.2. Subclasses and Child Objects
        1. 15.8.2.1. Subclassing the root type
        2. 15.8.2.2. Serializing child objects
        3. 15.8.2.3. Subclassing child objects
      3. 15.8.3. Serializing Collections
        1. 15.8.3.1. Working with subclassed collection elements
      4. 15.8.4. IXmlSerializable
  19. 16. Assemblies
    1. 16.1. What's in an Assembly
      1. 16.1.1. The Assembly Manifest
        1. 16.1.1.1. Specifying assembly attributes
      2. 16.1.2. The Application Manifest
        1. 16.1.2.1. Deploying an application manifest
      3. 16.1.3. Modules
      4. 16.1.4. The Assembly Class
    2. 16.2. Signing an Assembly
      1. 16.2.1. How to Sign an Assembly
      2. 16.2.2. Delay Signing
    3. 16.3. Assembly Names
      1. 16.3.1. Fully Qualified Names
      2. 16.3.2. The AssemblyName Class
    4. 16.4. The Global Assembly Cache
      1. 16.4.1. How to Install Assemblies to the GAC
      2. 16.4.2. GAC and Versioning
    5. 16.5. Resources and Satellite Assemblies
      1. 16.5.1. Directly Embedding Resources
      2. 16.5.2. .resources Files
      3. 16.5.3. .resx Files
        1. 16.5.3.1. Creating a .resx file at the command line
        2. 16.5.3.2. Reading .resources files
        3. 16.5.3.3. Creating a pack URI resource in Visual Studio
      4. 16.5.4. Satellite Assemblies
        1. 16.5.4.1. Building satellite assemblies
        2. 16.5.4.2. Testing satellite assemblies
        3. 16.5.4.3. Visual Studio designer support
      5. 16.5.5. Cultures and Subcultures
    6. 16.6. Resolving and Loading Assemblies
      1. 16.6.1. Assembly and Type Resolution Rules
      2. 16.6.2. AssemblyResolve
      3. 16.6.3. Loading Assemblies
        1. 16.6.3.1. Loading from a filename
    7. 16.7. Deploying Assemblies Outside the Base Folder
    8. 16.8. Packing a Single-File Executable
      1. 16.8.1. Selective Patching
    9. 16.9. Working with Unreferenced Assemblies
  20. 17. Reflection and Metadata
    1. 17.1. Reflecting and Activating Types
      1. 17.1.1. Obtaining a Type
        1. 17.1.1.1. Obtaining array types
        2. 17.1.1.2. Obtaining nested types
      2. 17.1.2. Type Names
        1. 17.1.2.1. Nested type names
        2. 17.1.2.2. Generic type names
        3. 17.1.2.3. Array and pointer type names
        4. 17.1.2.4. ref and out parameter type names
      3. 17.1.3. Base Types and Interfaces
      4. 17.1.4. Instantiating Types
      5. 17.1.5. Generic Types
    2. 17.2. Reflecting and Invoking Members
      1. 17.2.1. Member Types
      2. 17.2.2. C# Members Versus CLR Members
      3. 17.2.3. Generic Type Members
      4. 17.2.4. Dynamically Invoking a Member
      5. 17.2.5. Method Parameters
      6. 17.2.6. Using Delegates for Performance
      7. 17.2.7. Accessing Nonpublic Members
        1. 17.2.7.1. The BindingFlags enum
      8. 17.2.8. Generic Methods
      9. 17.2.9. Anonymously Calling Members of a Generic Type
    3. 17.3. Reflecting Assemblies
      1. 17.3.1. Loading an Assembly into a Reflection-Only Context
      2. 17.3.2. Modules
    4. 17.4. Working with Attributes
      1. 17.4.1. Attribute Basics
      2. 17.4.2. The AttributeUsage Attribute
      3. 17.4.3. Defining Your Own Attribute
      4. 17.4.4. Retrieving Attributes at Runtime
      5. 17.4.5. Retrieving Attributes in the Reflection-Only Context
    5. 17.5. Dynamic Code Generation
      1. 17.5.1. Generating IL with DynamicMethod
      2. 17.5.2. The Evaluation Stack
      3. 17.5.3. Passing Arguments to a Dynamic Method
      4. 17.5.4. Generating Local Variables
      5. 17.5.5. Branching
      6. 17.5.6. Instantiating Objects and Calling Instance Methods
      7. 17.5.7. Exception Handling
    6. 17.6. Emitting Assemblies and Types
      1. 17.6.1. Saving Emitted Assemblies
      2. 17.6.2. The Reflection.Emit Object Model
    7. 17.7. Emitting Type Members
      1. 17.7.1. Emitting Methods
        1. 17.7.1.1. Generating instance methods
        2. 17.7.1.2. HideBySig
      2. 17.7.2. Emitting Fields and Properties
      3. 17.7.3. Emitting Constructors
        1. 17.7.3.1. Calling base constructors
      4. 17.7.4. Attaching Attributes
    8. 17.8. Emitting Generic Methods and Types
      1. 17.8.1. Defining Generic Methods
      2. 17.8.2. Defining Generic Types
    9. 17.9. Awkward Emission Targets
      1. 17.9.1. Uncreated Closed Generics
      2. 17.9.2. Circular Dependencies
    10. 17.10. Parsing IL
      1. 17.10.1. Writing a Disassembler
  21. 18. Security
    1. 18.1. Permissions
      1. 18.1.1. CodeAccessPermission and PrincipalPermission
        1. 18.1.1.1. IPermission
      2. 18.1.2. PermissionSet
      3. 18.1.3. Declarative Versus Imperative Security
    2. 18.2. Code Access Security
      1. 18.2.1. How the CLR Allocates Permissions
    3. 18.3. Running in a Sandbox
      1. 18.3.1. Optional Permissions
        1. 18.3.1.1. SecurityAction.RequestOptional
    4. 18.4. Sandboxing Another Assembly
      1. 18.4.1. Link Demands and Partially Trusted Callers
      2. 18.4.2. Making Assertions
    5. 18.5. Operating System Security
      1. 18.5.1. Running in a Standard User Account
      2. 18.5.2. Administrative Elevation and Virtualization
    6. 18.6. Identity and Role Security
      1. 18.6.1. Assigning Users and Roles
    7. 18.7. Cryptography Overview
    8. 18.8. Windows Data Protection
    9. 18.9. Hashing
    10. 18.10. Symmetric Encryption
      1. 18.10.1. Encrypting in Memory
      2. 18.10.2. Chaining Encryption Streams
      3. 18.10.3. Disposing Encryption Objects
      4. 18.10.4. Key Management
    11. 18.11. Public Key Encryption and Signing
      1. 18.11.1. The RSA Class
      2. 18.11.2. Digital Signing
  22. 19. Threading
    1. 19.1. Threading's Uses and Misuses
    2. 19.2. Getting Started
      1. 19.2.1. Passing Data to a Thread
      2. 19.2.2. Sharing Data Between Threads
      3. 19.2.3. Thread Pooling
        1. 19.2.3.1. Optimizing the pool
      4. 19.2.4. Foreground and Background Threads
      5. 19.2.5. Thread Priority
      6. 19.2.6. Exception Handling
    3. 19.3. Asynchronous Delegates
    4. 19.4. Synchronization
      1. 19.4.1. Blocking
      2. 19.4.2. Blocking Versus Spinning
        1. 19.4.2.1. SpinWait
    5. 19.5. Locking
      1. 19.5.1. Choosing the Synchronization Object
      2. 19.5.2. Nested Locking
      3. 19.5.3. When to Lock
      4. 19.5.4. Locking and Atomicity
      5. 19.5.5. Performance, Races, and Deadlocks
      6. 19.5.6. Mutex
      7. 19.5.7. Semaphore
    6. 19.6. Thread Safety
      1. 19.6.1. Thread Safety and .NET Framework Types
        1. 19.6.1.1. Locking around thread-safe objects
        2. 19.6.1.2. Static methods
      2. 19.6.2. Thread Safety in Application Servers
      3. 19.6.3. Thread Safety in Rich Client Applications
    7. 19.7. Nonblocking Synchronization
      1. 19.7.1. Atomicity and Interlocked
      2. 19.7.2. Memory Barriers and Volatility
    8. 19.8. Signaling with Event Wait Handles
      1. 19.8.1. Creating and Disposing Wait Handles
      2. 19.8.2. Two-Way Signaling
      3. 19.8.3. Creating a Cross-Process EventWaitHandle
      4. 19.8.4. Pooling Wait Handles
      5. 19.8.5. WaitAny, WaitAll, and SignalAndWait
    9. 19.9. Signaling with Wait and Pulse
      1. 19.9.1. How to Use Wait and Pulse
      2. 19.9.2. Producer/Consumer Queue
      3. 19.9.3. Wait Timeouts
      4. 19.9.4. Two-Way Signaling
      5. 19.9.5. Simulating Wait Handles
    10. 19.10. Interrupt and Abort
      1. 19.10.1. Interrupt
      2. 19.10.2. Abort
      3. 19.10.3. Safe Cancellation
    11. 19.11. Local Storage
    12. 19.12. BackgroundWorker
      1. 19.12.1. Subclassing BackgroundWorker
    13. 19.13. ReaderWriterLockSlim
      1. 19.13.1. Upgradeable Locks and Recursion
        1. 19.13.1.1. Lock recursion
    14. 19.14. Timers
      1. 19.14.1. Multithreaded Timers
      2. 19.14.2. Single-Threaded Timers
  23. 20. Asynchronous Methods
    1. 20.1. Why Asynchronous Methods Exist
    2. 20.2. Asynchronous Method Signatures
    3. 20.3. Asynchronous Methods Versus Asynchronous Delegates
    4. 20.4. Using Asynchronous Methods
    5. 20.5. Writing Asynchronous Methods
    6. 20.6. Fake Asynchronous Methods
    7. 20.7. Alternatives to Asynchronous Methods
    8. 20.8. Asynchronous Events
  24. 21. Application Domains
    1. 21.1. Application Domain Architecture
    2. 21.2. Creating and Destroying Application Domains
    3. 21.3. Using Multiple Application Domains
    4. 21.4. Using DoCallBack
    5. 21.5. Domains and Threads
    6. 21.6. Sharing Data Between Domains
      1. 21.6.1. Sharing Data Via Slots
      2. 21.6.2. Intra-Process Remoting
      3. 21.6.3. Isolating Types and Assemblies
        1. 21.6.3.1. Type discovery
  25. 22. Integrating with Native DLLs
    1. 22.1. Calling into DLLs
    2. 22.2. Marshaling Common Types
    3. 22.3. Marshaling Classes and Structs
    4. 22.4. In and Out Marshaling
    5. 22.5. Callbacks from Unmanaged Code
    6. 22.6. Simulating a C Union
    7. 22.7. Shared Memory
    8. 22.8. Mapping a Struct to Unmanaged Memory
      1. 22.8.1. fixed and fixed open_curly...close_curly
    9. 22.9. Interop Attribute Reference
      1. 22.9.1. The DllImport Attribute
      2. 22.9.2. The StructLayout Attribute
      3. 22.9.3. The FieldOffset Attribute
      4. 22.9.4. The MarshalAs Attribute
        1. 22.9.4.1. UnmanagedType members
  26. 23. Diagnostics
    1. 23.1. Conditional Compilation
      1. 23.1.1. Conditional Compilation Versus Static Variable Flags
      2. 23.1.2. The Conditional Attribute
        1. 23.1.2.1. Alternatives to the Conditional attribute
    2. 23.2. Debug and Trace Classes
      1. 23.2.1. TraceListener
      2. 23.2.2. Flushing and Closing Listeners
    3. 23.3. Debugger Integration
      1. 23.3.1. Attaching and Breaking
      2. 23.3.2. Debugger Attributes
    4. 23.4. Processes and Process Threads
      1. 23.4.1. Examining Running Processes
      2. 23.4.2. Examining Threads in a Process
    5. 23.5. StackTrace and StackFrame
    6. 23.6. Windows Event Logs
      1. 23.6.1. Writing to the Event Log
      2. 23.6.2. Reading the Event Log
      3. 23.6.3. Monitoring the Event Log
    7. 23.7. Performance Counters
      1. 23.7.1. Enumerating the Available Counters
      2. 23.7.2. Reading Performance Counter Data
      3. 23.7.3. Creating Counters and Writing Performance Data
    8. 23.8. The Stopwatch Class
  27. 24. Regular Expressions
    1. 24.1. Regular Expression Basics
      1. 24.1.1. Compiled Regular Expressions
      2. 24.1.2. RegexOptions
      3. 24.1.3. Character Escapes
      4. 24.1.4. Character Sets
    2. 24.2. Quantifiers
      1. 24.2.1. Greedy Versus Lazy Quantifiers
    3. 24.3. Zero-Width Assertions
      1. 24.3.1. Lookahead and Lookbehind
      2. 24.3.2. Anchors
      3. 24.3.3. Word Boundaries
    4. 24.4. Groups
      1. 24.4.1. Named Groups
    5. 24.5. Replacing and Splitting Text
      1. 24.5.1. MatchEvaluator Delegate
      2. 24.5.2. Splitting Text
    6. 24.6. Cookbook Regular Expressions
      1. 24.6.1. Recipes
        1. 24.6.1.1. Matching U.S. Social Security number/phone number
        2. 24.6.1.2. Extracting "name = value" pairs (one per line)
        3. 24.6.1.3. Strong password validation
        4. 24.6.1.4. Lines of at least 80 characters
        5. 24.6.1.5. Parsing dates/times (N/N/N H:M:S AM/PM)
        6. 24.6.1.6. Matching Roman numerals
        7. 24.6.1.7. Removing repeated words
        8. 24.6.1.8. Word count
        9. 24.6.1.9. Matching a Guid
        10. 24.6.1.10. Parsing an XML tag
        11. 24.6.1.11. Splitting a camel-cased word
        12. 24.6.1.12. Obtaining a legal filename
        13. 24.6.1.13. Escaping Unicode characters for HTML
    7. 24.7. Regular Expressions Language Reference
  28. A. C# Keywords
  29. B. Namespace-to-Assembly Reference
  30. About the Authors
  31. Colophon
  32. Copyright