| |
| |
C# 3.0 Cookbook#x2122 | |
| |
| |
Third Edition | |
| |
| |
Dedication | |
| |
| |
Preface | |
| |
| |
| |
Who This Book Is For | |
| |
| |
| |
What You Need to Use This Book | |
| |
| |
| |
Platform Notes | |
| |
| |
| |
How This Book Is Organized | |
| |
| |
| |
What Was Left Out | |
| |
| |
| |
Conventions Used in This Book | |
| |
| |
| |
About the Code | |
| |
| |
| |
Using Code Examples | |
| |
| |
| |
Comments and Questions | |
| |
| |
| |
Safari#xAE; Books Online | |
| |
| |
| |
Acknowledgments | |
| |
| |
| |
Language Integrated Query (LINQ) | |
| |
| |
| |
Introduction | |
| |
| |
| |
Query a Message Queue | |
| |
| |
| |
Using Set Semantics with Data | |
| |
| |
| |
Reuse Parameterized Queries with LINQ to SQL | |
| |
| |
| |
Sort Results in a Culture-Sensitive Manner | |
| |
| |
| |
Adding Functional Extensions for Use with LINQ | |
| |
| |
| |
Query and Join Across Data Repositories | |
| |
| |
| |
Querying Configuration Files with LINQ | |
| |
| |
| |
Creating XML Straight from a Database | |
| |
| |
| |
Being Selective About Your Query Results | |
| |
| |
| |
Using LINQ with Collections That Don't Support IEnumerable | |
| |
| |
| |
Strings and Characters | |
| |
| |
| |
Introduction | |
| |
| |
| |
Determining the Kind of Character a Char Contains | |
| |
| |
| |
Controlling Case Sensitivity When Comparing Two Characters | |
| |
| |
| |
Finding the Location of All Occurrences of a String Within Another String | |
| |
| |
| |
Controlling Case Sensitivity When Comparing Two Strings | |
| |
| |
| |
Comparing a String to the Beginning or End of a Second String | |
| |
| |
| |
Inserting Text into a String | |
| |
| |
| |
Removing or Replacing Characters Within a String | |
| |
| |
| |
Encoding Binary Data As Base64 | |
| |
| |
| |
Decoding a Base64-Encoded Binary | |
| |
| |
| |
Converting a String Returned As a Byte[] Back into a String | |
| |
| |
| |
Passing a String to a Method That Accepts Only a Byte[] | |
| |
| |
| |
Converting Strings to Other Types | |
| |
| |
| |
Creating a Delimited String | |
| |
| |
| |
Extracting Items from a Delimited String | |
| |
| |
| |
Iterating over Each Character in a String | |
| |
| |
| |
Pruning Characters from the Head and/or Tail of a String | |
| |
| |
| |
Testing a String for Null or Empty | |
| |
| |
| |
Appending a Line | |
| |
| |
| |
Classes and Structures | |
| |
| |
| |
Introduction | |
| |
| |
| |
Creating Union-Type Structures | |
| |
| |
| |
Making a Type Sortable | |
| |
| |
| |
Making a Type Searchable | |
| |
| |
| |
Indirectly Overloading the +=, -=, /=, and = Operators | |
| |
| |
| |
Indirectly Overloading the &&, and ?: Operators | |
| |
| |
| |
Making Error-Free Expressions | |
| |
| |
| |
Reducing Your Boolean Logic | |
| |
| |
| |
Converting Between Simple Types in a Programming Language-Agnostic Manner | |
| |
| |
| |
Determining When to Use the cast Operator, the as Operator, or the is Operator | |
| |
| |
| |
Casting with the as Operator | |
| |
| |
| |
Determining a Variable's Type with the is Operator | |
| |
| |
| |
Returning Multiple Items from a Method | |
| |
| |
| |
Parsing Command-Line Parameters | |
| |
| |
| |
Initializing a Constant Field at Runtime | |
| |
| |
| |
Building Cloneable Classes | |
| |
| |
| |
Assuring an Object's Disposal | |
| |
| |
| |
Disposing of Unmanaged Resources | |
| |
| |
| |
Determining Where Boxing and Unboxing Occur | |
| |
| |
| |
Generics | |
| |
| |
| |
Introduction | |
| |
| |
| |
Deciding When and Where to Use Generics | |
| |
| |
| |
Understanding Generic Types | |
| |
| |
| |
Replacing the ArrayList with Its Generic Counterpart | |
| |
| |
| |
Replacing the Stack and Queue with Their Generic Counterparts | |
| |
| |
| |
Using a Linked List | |
| |
| |
| |
Creating a Value Type That Can Be Initialized to Null | |
| |
| |
| |
Reversing the Contents of a Sorted List | |
| |
| |
| |
Making Read-Only Collections the Generic Way | |
| |
| |
| |
Replacing the Hashtable with Its Generic Counterpart | |
| |
| |
| |
Using foreach with Generic Dictionary Types | |
| |
| |
| |
Constraining Type Arguments | |
| |
| |
| |
Initializing Generic Variables to Their Default Values | |
| |
| |
| |
Collections | |
| |
| |
| |
Introduction | |
| |
| |
| |
Swapping Two Elements in an Array | |
| |
| |
| |
Reversing an Array Quickly | |
| |
| |
| |
Writing a More Flexible StackTrace Class | |
| |
| |
| |
Determining the Number of Times an Item Appears in a List | |
| |
| |
| |
Retrieving All Instances of a Specific Item in a List | |
| |
| |
| |
Inserting and Removing Items from an Array | |
| |
| |
| |
Keeping Your List Sorted | |
| |
| |
| |
Sorting a Dictionary's Keys and/or Values | |
| |
| |
| |
Creating a Dictionary with Max and Min Value Boundaries | |
| |
| |
| |
Storing Snapshots of Lists in an Array | |
| |
| |
| |
Persist | |