Please consider the latest edition.
-
Chapter 1 Numbers
-
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
-
Test for an Even or Odd Value
-
Obtaining the Most- or Least-Significant Bits of a Number
-
Converting a Number in Another Base to Base10
-
Determining Whether a String Is a Valid Number
-
Rounding a Floating-Point Value
-
Different Rounding Algorithms
-
Converting Celsius to Fahrenheit
-
Converting Fahrenheit to Celsius
-
Safely Performing a Narrowing Numeric Cast
-
Finding the Length of Any Three Sidesof a Right Triangle
-
Finding the Angles of a Right Triangle
-
-
Chapter 2 Strings and Characters
-
Determining the Kind of Character
-
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 Occurrencesof a String Within Another String
-
The Poor Man's Tokenizer
-
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 Their Equivalent Value Type
-
Formatting Data in Strings
-
Creating a Delimited String
-
Extracting Items from a Delimited String
-
Setting the Maximum Number of Characters a String Can Contain
-
Iterating Over Each Character in a String
-
Improving String Comparison Performance
-
Improving StringBuilder Performance
-
Pruning Characters from the Headand/or Tail of a String
-
-
Chapter 3 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
-
Polymorphism via Concrete or Abstract Base Classes
-
Making a Type Sortable
-
Making a Type Searchable
-
Indirectly Overloading the +=, -=, /=, and *= Operators
-
Indirectly Overloading the &&, ||, and ?: Operators
-
Improving the Performance of a Structure's Equals Method
-
Turning Bits On or Off
-
Making Error-Free Expressions
-
Minimizing (Reducing) Your Boolean Logic
-
Converting Between Simple Types in a Language Agnostic Manner
-
Determining Whether to Use theCast Operator, the as Operator, or theis Operator
-
Casting with the as Operator
-
Determining a Variable's Type with the is Operator
-
Polymorphism via Interfaces
-
Calling the Same Method on Multiple Object Types
-
Adding a Notification Callback Using an Interface
-
Using Multiple Entry Points toVersion 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
-
Implementing Nested foreach Functionality in a Class
-
Building Cloneable Classes
-
Assuring an Object's Disposal
-
Releasing a COM Object ThroughManaged Code
-
Creating an Object Cache
-
The Single Instance Object
-
Choosing a Serializer
-
Creating Custom Enumerators
-
Rolling Back Object Changes
-
Disposing of Unmanaged Resources
-
Determining Where Boxing and Unboxing Occur
-
-
Chapter 4 Enumerations
-
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 Bitmask
-
Determining Whether One or More Enumeration Flags Are Set
-
-
Chapter 5 Exception Handling
-
Verifying Critical Parameters
-
Indicating Where Exceptions Originate
-
Choosing when to Throw a Particular Exception
-
Handling Derived Exceptions Individually
-
Assuring Exceptions are Not Lost when Using Finally Blocks
-
Handling Exceptions Thrown from Methods Invoked via Reflection
-
Debugging Problems whenLoading an Assembly
-
HRESULT-Exception Mapping
-
Handling User-Defined HRESULTs
-
Preventing Unhandled Exceptions
-
Displaying Exception Information
-
Getting to the Root of a Problem Quickly
-
Creating a New Exception Type
-
Obtaining a Stack Trace
-
Breaking on a First Chance Exception
-
Preventing the Nefarious TypeInitializationException
-
Handling Exceptions Thrown from an Asynchronous Delegate
-
-
Chapter 6 Diagnostics
-
Controlling Tracing Output inProduction Code
-
Providing Fine-Grained Control Over Debugging/Tracing Output
-
Creating Your Own Custom Switch Class
-
A Custom Trace Class that Outputs Information in an XML Format
-
Conditionally Compiling Blocks of Code
-
Determining Whether a Process Has Stopped Responding
-
Using One or More Event Logs in Your Application
-
Changing the Maximum Size of a Custom Event Log
-
Searching Event Log Entries
-
Watching the Event Log for a Specific Entry
-
Finding All Sources Belonging to a Specific Event Log
-
Implementing a Simple Performance Counter
-
Implementing Performance Counters that Require a Base Counter
-
Enable/Disable Complex Tracing Code
-
-
Chapter 7 Delegates and Events
-
Controlling when and if a Delegate Fires Within a Multicast Delegate
-
Obtaining Return Values from Each Delegate in a Multicast Delegate
-
Handling Exceptions Individually for Each Delegate in a Multicast Delegate
-
Converting a Synchronous Delegate to an Asynchronous Delegate
-
Adding Events to a Sealed Class
-
Passing Specialized Parameters to and from an Event
-
An Advanced Interface Search Mechanism
-
An Advanced Member Search Mechanism
-
Observing Additions and Modifications to a Hashtable
-
Using the Windows Keyboard Hook
-
Using Windows Hooks to Manipulate the Mouse
-
-
Chapter 8 Regular Expressions
-
Enumerating Matches
-
Extracting Groups from a MatchCollection
-
Verifying the Syntax of a Regular Expression
-
Quickly Finding Only the Last Match in a String
-
Replacing Characters or Words in a String
-
Augmenting the Basic String Replacement Function
-
A Better Tokenizer
-
Compiling Regular Expressions
-
Counting Lines of Text
-
Returning the Entire Line in Which a Match Is Found
-
Finding a Particular Occurrence of a Match
-
Using Common Patterns
-
Documenting Your Regular Expressions
-
-
Chapter 9 Collections
-
Swapping Two Elements in an Array
-
Quickly Reversing an Array
-
Reversing a Two-Dimensional Array
-
Reversing a Jagged Array
-
A More Flexible StackTrace Class
-
Determining the Number of Times an Item Appears in an ArrayList
-
Retrieving All Instances of a Specific Itemin an ArrayList
-
Inserting and Removing Items from an Array
-
Keeping Your ArrayList Sorted
-
Sorting a Hashtable's Keys and/or Values
-
Creating a Hashtable with Max and Min Size Boundaries
-
Creating a Hashtable with Max and Min Value Boundaries
-
Displaying an Array's Data as a Delimited String
-
Storing Snapshots of Lists in an Array
-
Creating a Strongly Typed Collection
-
Persisting a Collection Between Application Sessions
-
-
Chapter 10 Data Structures and Algorithms
-
Creating a Hash Code for a Data Type
-
Creating a Priority Queue
-
Creating a More Versatile Queue
-
Determining Where Characters or Strings Do Not Balance
-
Creating a One-to-Many Map (MultiMap)
-
Creating a Binary Tree
-
Creating an n-ary Tree
-
Creating a Set Object
-
-
Chapter 11 Filesystem I/O
-
Creating, Copying, Moving, and Deleting a File
-
Manipulating File Attributes
-
Renaming a File
-
Determining Whether a File Exists
-
Choosing a Method of Opening a File or Stream for Reading and/or Writing
-
Randomly Accessing Part of a File
-
Outputting a Platform-Independent EOL Character
-
Create, Write to, and Read from a File
-
Determining Whether a Directory Exists
-
Creating, Moving, and Deleting a Directory
-
Manipulating Directory Attributes
-
Renaming a Directory
-
Searching for Directories or FilesUsing Wildcards
-
Obtaining the Directory Tree
-
Parsing a Path
-
Parsing Paths in Environment Variables
-
Verifying a Path
-
Using a Temporary File in Your Application
-
Opening a File Stream with just aFile Handle
-
Write to Multiple Output Files at One Time
-
Launching and Interacting withConsole Utilities
-
Locking Subsections of a File
-
Watching the Filesystem for Specific Changes to One or More Files or Directories
-
Waiting for an Action to Occurin the Filesystem
-
Comparing Version Information of Two Executable Modules
-
-
Chapter 12 Reflection
-
Listing Imported Assemblies
-
Listing Exported Types
-
Finding Overridden Methods
-
Finding Members in an Assembly
-
Finding Members Within an Interface
-
Obtaining Types Nested Within a Type
-
Displaying the Inheritance Hierarchy for a Type
-
Finding the Subclasses of a Type
-
Finding All Serializable Types Within an Assembly
-
Controlling Additions to an ArrayList Through Attributes
-
Filtering Output when Obtaining Members
-
Dynamically Invoking Members
-
-
Chapter 13 Networking
-
Converting an IP Address to a Hostname
-
Converting a Hostname to an IP Address
-
Parsing a URI
-
Forming an Absolute URI
-
Handling Web Server Errors
-
Communicating with a Web Server
-
Going Through a Proxy
-
Obtaining the HTML from a URL
-
Writing a TCP Server
-
Writing a TCP Client
-
Simulating Form Execution
-
Downloading Data from a Server
-
Using Named Pipes to Communicate
-
-
Chapter 14 Security
-
Controlling Access to Types in aLocal Assembly
-
Encrypting/Decrypting a String
-
Encrypting and Decrypting a File
-
Cleaning Up Cryptography Information
-
Verifying that a String Is Uncorrupted During Transmission
-
Wrapping a String Hash for Ease of Use
-
A Better Random Number Generator
-
Securely Storing Data
-
Making a Security Assert Safe
-
Preventing Malicious Modifications to an Assembly
-
Verifying that an Assembly Has Been Granted Specific Permissions
-
Minimizing the Attack Surface of an Assembly
-
-
Chapter 15 Threading
-
Creating Per-Thread Static Fields
-
Providing Thread Safe Access to Class Members
-
Preventing Silent Thread Termination
-
Polling an Asynchronous Delegate
-
Timing Out an Asynchronous Delegate
-
Being Notified of the Completionof an Asynchronous Delegate
-
Waiting for Worker Thread Completion
-
Synchronizing the Reading and Writingof a Resource Efficiently
-
Determining Whether a Requestfor a Pooled Thread Will Be Queued
-
Waiting for All Threads in theThread Pool to Finish
-
Configuring a Timer
-
Storing Thread-Specific Data Privately
-
-
Chapter 16 Unsafe Code
-
Controlling Changes to Pointers Passedto Methods
-
Comparing Pointers
-
Navigating Arrays
-
Manipulating a Pointer to a Fixed Array
-
Returning a Pointer to a Particular Element in an Array
-
Creating and Using an Array of Pointers
-
Creating and Using an Array of Pointersto Unknown Types
-
Switching Unknown Pointer Types
-
Breaking Up Larger Numbers into Their Equivalent Byte Array Representation
-
Converting Pointers to a Byte[ ], SByte[ ],or Char[ ] to a String
-
-
Chapter 17 XML
-
Reading and Accessing XML Datain Document Order
-
Reading XML on the Web
-
Querying the Contents of an XML Document
-
Validating XML
-
Creating an XML Document Programmatically
-
Detecting Changes to an XML Document
-
Handling Invalid Characters in anXML String
-
Transforming XML to HTML
-
Tearing Apart an XML Document
-
Putting Together an XML Document
-
-
Colophon
- Title:
- C# Cookbook
- By:
- Stephen Teilhet, Jay Hilyard
- Publisher:
- O'Reilly Media
- Formats:
-
- Safari Books Online
- Print Release:
- January 2004
- Pages:
- 864
- Print ISBN:
- 978-0-596-00339-5
- | ISBN 10:
- 0-596-00339-0
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal on the cover of C# Cookbook is a garter snake (Thamnophis sirtalis). Named because their longitudinal stripes resemble those on garters once used to hold up men's socks, garter snakes are easily identified by their distinctive stripes: a narrow stripe down the middle of the back with a broad stripe on each side of it. Color and pattern variations enable them to blend into their native environments, helping them evade predators. They are the most common snake in North America and the only species of snake found in Alaska.
Garter snakes have keeled scales--one or more ridges down the central axis of the scales--giving them a rough texture and lackluster appearance. Adult garter snakes generally range in length between 46 and 130 centimeters (one and a half feet to over four feet). Females are usually larger than males, with shorter tails and a bulge where the body and tail meet.
Female garters are ovoviviparous, meaning they deliver "live" young that have gestated in soft eggs. Upon delivery, most of the eggs and mucous membranes have broken, which makes their births appear live. Occasionally, a baby will be born still inside its soft shell. A female will usually deliver 10 to 40 babies: the largest recorded number of live babies birthed by a garter snake is 98. Once emerging from their mothers, baby garters are completely independent and must begin fending for themselves. During this time they are most susceptible to predation, and over half of all baby garters die before they are one year old.
Garter snakes are one of the few animals able to eat toads, newts, and other amphibians with strong chemical defenses. Although diets vary depending on their environments, garter snakes mostly eat earthworms and amphibians; however, they occasionally dine on baby birds, fish, and small rodents. Garter snakes have toxic saliva (harmless to humans), which they use to stun or kill their prey before swallowing them whole. Marlowe Shaeffer was the production editor and proofreader for C# Cookbook. Nancy Kotary was the copyeditor. Reg Aubry and Darren Kelly provided quality control. Jamie Peppard and Mary Agner provided production assistance. Angela Howard wrote the index.
Emma Colby designed the cover of this book, based on a series design by Edie Freedman. The cover image is a 19th-century engraving from the Dover Pictorial Archive. Emma Colby produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.
David Futato designed the interior layout. This book was converted by Julie Hawks to FrameMaker 5.5.6 with a format conversion tool created by Erik Ray, Jason McIntosh, Neil Walls, and Mike Sierra that uses Perl and XML technologies. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia FreeHand 9 and Adobe Photoshop 6. The tip and warning icons were drawn by Christopher Bing. This colophon was written by Marlowe Shaeffer.
