| |
| |
Preface | |
| |
| |
| |
Numbers and Enumerations | |
| |
| |
| |
Determining Approximate Equality Between a Fraction and Floating-Point Value | |
| |
| |
| |
Converting Degrees to Radians | |
| |
| |
| |
Converting Radians to Degrees | |
| |
| |
| |
Using the Bitwise Complement Operator with Various Data Types | |
| |
| |
| |
Testing for an Even or Odd Value | |
| |
| |
| |
Obtaining the High Word or Low Word of a Number | |
| |
| |
| |
Converting a Number in Another Base to Base10 | |
| |
| |
| |
Determining Whether a String Is a Valid Number | |
| |
| |
| |
Rounding a Floating-Point Value | |
| |
| |
| |
Choosing a Rounding Algorithm | |
| |
| |
| |
Converting Celsius to Fahrenheit | |
| |
| |
| |
Converting Fahrenheit to Celsius | |
| |
| |
| |
Safely Performing a Narrowing Numeric Cast | |
| |
| |
| |
Finding the Length of Any Three Sides of a Right Triangle | |
| |
| |
| |
Finding the Angles of a Right Triangle | |
| |
| |
| |
Displaying an Enumeration Value as a String | |
| |
| |
| |
Converting Plain Text to an Equivalent Enumeration Value | |
| |
| |
| |
Testing for a Valid Enumeration Value | |
| |
| |
| |
Testing for a Valid Enumeration of Flags | |
| |
| |
| |
Using Enumerated Members in a Bit Mask | |
| |
| |
| |
Determining if One or More Enumeration Flags Are Set | |
| |
| |
| |
Determining the Integral Part of a Decimal or Double | |
| |
| |
| |
Strings and Characters | |
| |
| |
| |
Determining the Kind of Character a char Contains | |
| |
| |
| |
Determining Whether a Character Is Within a Specified Range | |
| |
| |
| |
Controlling Case Sensitivity When Comparing Two Characters | |
| |
| |
| |
Finding All Occurrences of a Character Within a String | |
| |
| |
| |
Finding the Location of All Occurrences of a String Within Another String | |
| |
| |
| |
Implementing a Poor Man''s Tokenizer to Deconstruct a 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 String2.11 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 | |
| |
| |
| |
Formatting Data in Strings | |
| |
| |
| |
Creating a Delimited String | |
| |
| |
| |
Extracting Items from a Delimited String | |
| |
| |
| |
Setting the Maximum Number of Characters a StringBuilder Can Contain | |
| |
| |
| |
Iterating over Each Character in a String | |
| |
| |
| |
Improving String Comparison Performance | |
| |
| |
| |
Improving StringBuilder Performance | |
| |
| |
| |
Pruning Characters from the Head and/or Tail of a String | |
| |
| |
| |
Testing a String for Null or Empty | |
| |
| |
| |
Appending a Line | |
| |
| |
| |
Encoding Chunks of Data | |
| |
| |
| |
Classes and Structures | |
| |
| |
| |
Creating Union-Type Structures | |
| |
| |
| |
Allowing a Type to Represent Itself as a String | |
| |
| |
| |
Converting a String Representation of an Object into an Actual Object | |
| |
| |
| |
Implementing Polymorphism with Abstract Base Classes | |
| |
| |
| |
Making a Type Sortable | |
| |
| |
| |
Making a Type Searchable | |
| |
| |
| |
Indirectly Overloading the +=, -=, /=, and = Operators | |
| |
| |
| |
Indirectly Overloading the &&, and ?: Operators | |
| |
| |
| |
Turning Bits On or Off | |
| |
| |
| |
Making Error-Free Expressions | |
| |
| |
| |
Minimizing (Reducing) Your Boolean Logic | |
| |
| |
| |
Converting Between Simple Types in a 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 | |
| |
| |
| |
Implementing Polymorphism with Interfaces | |
| |
| |
| |
Calling the Same Method on Multiple Object Types | |
| |
| |
| |
Adding a Notification Callback Using an Interface | |
| |
| |
| |
Using Multiple Entry Points to Version an Application | |
| |
| |
| |
Preventing the Creation of an Only Partially Initialized Object | |
| |
| |
| |
Returning Multiple Items from a Method | |
| |
| |
| |
Parsing Command-Line Parameters | |
| |
| |
| |
Retrofitting a Class to Interoperate with COM | |
| |
| |
| |
Initializing a Constant Field at Runtime | |
| |
| |
| |
Writing Code That Is Compatible with the Widest Range of Managed Languages | |
| |
| |
| |
Building Cloneable Classes | |
| |
| |
| |
Assuring an Object''s Disposal | |
| |
| |
| |
Releasing a COM Object Through Managed Code | |
| |
| |
| |
Creating an Object Cache | |
| |
| |
| |
Rolling Back Object Changes | |
| |
| |
| |
Disposing of Unmanaged Resources | |
| |
| |
| |
Determining Where Boxing and Unboxing Occur | |
| |
| |
| |
Generics | |
| |
| |
| |
Deciding When and Where to Use Generics | |
| |
| |
| |
Understanding Generic | |