skip to content
C♯ cookbook Preview this item
ClosePreview this item
Checking...

C♯ cookbook

Author: Jay Hilyard; Stephen Teilhet
Publisher: Beijing ; Sebastopol, CA : O'Reilly, ©2006.
Edition/Format:   Print book : English : 2nd edView all editions and formats
Summary:

Offers more than 100 new code solutions to common problems that you face as a C# programmer. Nearly every solution, or 'recipe' in this work contains a complete, documented code sample showing you  Read more...

Rating:

(not yet rated) 0 with reviews - Be the first.

Subjects
More like this

Find a copy in the library

&AllPage.SpinnerRetrieving; Finding libraries that hold this item...

Details

Document Type: Book
All Authors / Contributors: Jay Hilyard; Stephen Teilhet
ISBN: 0596100639 9780596100636
OCLC Number: 71954661
Notes: Teilhet's name appears first on the earlier edition.
"Over 300 solutions for C♯ programmers"--Cover.
"Updated for C♯ 2.0 and .NET 2.0"--Cover.
Includes index.
Description: xxviii, 1154 pages : illustrations ; 24 cm
Contents: Preface 1. Numbers and Enumerations 1.1 Determining Approximate Equality Between a Fraction and Floating-Point Value 1.2 Converting Degrees to Radians 1.3 Converting Radians to Degrees 1.4 Using the Bitwise Complement Operator with Various Data Types 1.5 Testing for an Even or Odd Value 1.6 Obtaining the High Word or Low Word of a Number 1.7 Converting a Number in Another Base to Base10 1.8 Determining Whether a String Is a Valid Number 1.9 Rounding a Floating-Point Value 1.10 Choosing a Rounding Algorithm 1.11 Converting Celsius to Fahrenheit 1.12 Converting Fahrenheit to Celsius 1.13 Safely Performing a Narrowing Numeric Cast 1.14 Finding the Length of Any Three Sides of a Right Triangle 1.15 Finding the Angles of a Right Triangle 1.16 Displaying an Enumeration Value as a String 1.17 Converting Plain Text to an Equivalent Enumeration Value 1.18 Testing for a Valid Enumeration Value 1.19 Testing for a Valid Enumeration of Flags 1.20 Using Enumerated Members in a Bit Mask 1.21 Determining if One or More Enumeration Flags Are Set 1.22 Determining the Integral Part of a Decimal or Double 2. Strings and Characters 2.1 Determining the Kind of Character a char Contains 2.2 Determining Whether a Character Is Within a Specified Range 2.3 Controlling Case Sensitivity When Comparing Two Characters 2.4 Finding All Occurrences of a Character Within a String 2.5 Finding the Location of All Occurrences of a String Within Another String 2.6 Implementing a Poor Man's Tokenizer to Deconstruct a String 2.7 Controlling Case Sensitivity When Comparing Two Strings 2.8 Comparing a String to the Beginning or End of a Second String 2.9 Inserting Text into a String 2.10 Removing or Replacing Characters Within a String 2.11 Encoding Binary Data as Base64 2.12 Decoding a Base64-Encoded Binary 2.13 Converting a String Returned as a Byte[ ] Back into a String 2.14 Passing a String to a Method That Accepts only a Byte[ ] 2.15 Converting Strings to Other Types 2.16 Formatting Data in Strings 2.17 Creating a Delimited String 2.18 Extracting Items from a Delimited String 2.19 Setting the Maximum Number of Characters a StringBuilder Can Contain 2.20 Iterating over Each Character in a String 2.21 Improving String Comparison Performance 2.22 Improving StringBuilder Performance 2.23 Pruning Characters from the Head and/or Tail of a String 2.24 Testing a String for Null or Empty 2.25 Appending a Line 2.26 Encoding Chunks of Data 3. Classes and Structures 3.1 Creating Union-Type Structures 3.2 Allowing a Type to Represent Itself as a String 3.3 Converting a String Representation of an Object into an Actual Object 3.4 Implementing Polymorphism with Abstract Base Classes 3.5 Making a Type Sortable 3.6 Making a Type Searchable 3.7 Indirectly Overloading the +=, -=, /=, and *= Operators 3.8 Indirectly Overloading the &&, ||, and ?: Operators 3.9 Turning Bits On or Off 3.10 Making Error-Free Expressions 3.11 Minimizing (Reducing) Your Boolean Logic 3.12 Converting Between Simple Types in a Language-Agnostic Manner 3.13 Determining When to Use the Cast Operator, the as Operator, or the is Operator 3.14 Casting with the as Operator 3.15 Determining a Variable's Type with the is Operator 3.16 Implementing Polymorphism with Interfaces 3.17 Calling the Same Method on Multiple Object Types 3.18 Adding a Notification Callback Using an Interface 3.19 Using Multiple Entry Points to Version an Application 3.20 Preventing the Creation of an Only Partially Initialized Object 3.21 Returning Multiple Items from a Method 3.22 Parsing Command-Line Parameters 3.23 Retrofitting a Class to Interoperate with COM 3.24 Initializing a Constant Field at Runtime 3.25 Writing Code That Is Compatible with the Widest Range of Managed Languages 3.26 Building Cloneable Classes 3.27 Assuring an Object's Disposal 3.28 Releasing a COM Object Through Managed Code 3.29 Creating an Object Cache 3.30 Rolling Back Object Changes 3.31 Disposing of Unmanaged Resources 3.32 Determining Where Boxing and Unboxing Occur 4. Generics 4.1 Deciding When and Where to Use Generics 4.2 Understanding Generic Types 4.3 Getting the Type of a Generic Type 4.4 Replacing the ArrayList with Its Generic Counterpart 4.5 Replacing the Stack and Queue with Their Generic Counterparts 4.6 Implementing a Linked List 4.7 Creating a Value Type That Can be Initialized to Null 4.8 Reversing the Contents of a Sorted List 4.9 Making Read-Only Collections the Generic Way 4.10 Replacing the Hashtable with Its Generic Counterpart 4.11 Using foreach with Generic Dictionary Types 4.12 Constraining Type Arguments 4.13 Initializing Generic Variables to Their Default Values 5. Collections 5.1 Swapping Two Elements in an Array 5.2 Reversing an Array Quickly 5.3 Reversing a Two-Dimensional Array 5.4 Reversing a Jagged Array 5.5 Writing a More Flexible StackTrace Class 5.6 Determining the Number of Times an Item Appears in a List 5.7 Retrieving All Instances of a Specific Item in a List 5.8 Inserting and Removing Items from an Array 5.9 Keeping Your List Sorted 5.10 Sorting a Dictionary's Keys and/or Values 5.11 Creating a Dictionary with Max and Min Value Boundaries 5.12 Displaying an Array's Data as a Delimited String 5.13 Storing Snapshots of Lists in an Array 5.14 Persisting a Collection Between Application Sessions 5.15 Testing Every Element in an Array or List 5.16 Performing an Action on Each Element in an Array or List 5.17 Creating a Read-Only Array or List 6. Iterators and Partial Types 6.1 Implementing Nested foreach Functionality in a Class 6.2 Creating Custom Enumerators 6.3 Creating an Iterator on a Generic Type 6.4 Creating an Iterator on a Non-generic Type 6.5 Creating Iterators That Accept Parameters 6.6 Adding Multiple Iterators on a Single Type 6.7 Implementing Iterators as Overloaded Operators 6.8 Forcing an Iterator to Stop Iterating 6.9 Dealing with Finally Blocks and Iterators 6.10 Organizing Your Interface Implementations 6.11 Generating Code That Is No Longer in Your Main Code Paths 7. Exception Handling 7.1 Verifying Critical Parameters 7.2 Knowing When to Catch and Rethrow Exceptions 7.3 Identifying Exceptions and Their Usage 7.4 Handling Derived Exceptions Individually 7.5 Assuring Exceptions Are Not Lost When Using Finally Blocks 7.6 Handling Exceptions Thrown from Methods Invoked via Reflection 7.7 Debugging Problems When Loading an Assembly 7.8 Mapping Back and Forth Between Managed Exceptions and HRESULTs 7.9 Handling User-Defined HRESULTs 7.10 Preventing Unhandled Exceptions 7.11 Getting Exception Information 7.12 Getting to the Root of a Problem Quickly 7.13 Creating a New Exception Type 7.14 Obtaining a Stack Trace 7.15 Breaking on a First-Chance Exception 7.16 Preventing the Nefarious TypeInitializationException 7.17 Handling Exceptions Thrown from an Asynchronous Delegate 7.18 Giving Exceptions the Extra Info They Need with Exception.Data 7.19 Looking at Exceptions in a New Way Using Visualizers 7.20 Dealing with Unhandled Exceptions in WinForms Applications 8. Diagnostics 8.1 Controlling Tracing Output in Production Code 8.2 Providing Fine-Grained Control over Debugging/Tracing Output 8.3 Creating Your Own Custom Switch Class 8.4 Compiling Blocks of Code Conditionally 8.5 Determining Whether a Process Has Stopped Responding 8.6 Using Event Logs in Your Application 8.7 Changing the Maximum Size of a Custom Event Log 8.8 Searching Event Log Entries 8.9 Watching the Event Log for a Specific Entry 8.10 Finding All Sources Belonging to a Specific Event Log 8.11 Implementing a Simple Performance Counter 8.12 Implementing Performance Counters That Require a Base Counter 8.13 Enabling and Disabling Complex Tracing Code 8.14 Capturing Standard Output for a Process 8.15 Creating Custom Debugging Displays for Your Classes 8.16 Determining Current AppDomain Settings Information 8.17 Boosting the Priority of a Process Programmatically 8.18 Looking at Your Runtime Environment and Seeing What You Can Do About It 9. Delegates, Events, and Anonymous Methods 9.1 Controlling When and If a Delegate Fires Within a Multicast Delegate 9.2 Obtaining Return Values from Each Delegate in a Multicast Delegate 9.3 Handling Exceptions Individually for Each Delegate in a ulticast Delegate 9.4 Converting Delegate Invocation from Synchronous to Asynchronous 9.5 Wrapping Sealed Classes to Add Events 9.6 Passing Specialized Parameters to and from an Event 9.7 An Advanced Interface Search Mechanism 9.8 An Advanced Member Search Mechanism 9.9 Observing Additions and Modifications to a Hashtable 9.10 Using the Windows Keyboard Hook 9.11 Tracking and Responding to the Mouse 9.12 Using Anonymous Methods 9.13 Set Up Event Handlers Without the Mess 9.14 Using Different Parameter Modifiers in Anonymous Methods 9.15 Using Closures in C# 9.16 Performing Multiple Operations on a List Using Functors 10. Regular Expressions 10.1 Enumerating Matches 10.2 Extracting Groups from a MatchCollection 10.3 Verifying the Syntax of a Regular Expression 10.4 Quickly Finding Only the Last Match in a String 10.5 Replacing Characters or Words in a String 10.6 Augmenting the Basic String Replacement Function 10.7 Implementing a Better Tokenizer 10.8 Compiling Regular Expressions 10.9 Counting Lines of Text 10.10 Returning the Entire Line in Which a Match Is Found 10.11 Finding a Particular Occurrence of a Match 10.12 Using Common Patterns 10.13 Documenting Your Regular Expressions 10.14 Using Built-in Regular Expressions to Parse ASP.NET Pages 11. Data Structures and Algorithms 11.1 Creating a Hash Code for a Data Type 11.2 Creating a Priority Queue 11.3 Creating a Double Queue 11.4 Determining Where Characters or Strings Do Not Balance 11.5 Creating a One-to-Many Map (MultiMap) 11.6 Creating a Binary Tree 11.7 Creating an n-ary Tree 11.8 Creating a Set Object 12. Filesystem I/O 12.1 Creating, Copying, Moving, or Deleting a File 12.2 Manipulating File Attributes 12.3 Renaming a File 12.4 Determining Whether a File Exists 12.5 Choosing a Method of Opening a File or Stream for Reading and/or Writing 12.6 Accessing Part of a File Randomly 12.7 Outputting a Platform-Independent EOL Character 12.8 Creating, Writing to, and Reading from a File 12.9 Determining Whether a Directory Exists 12.10 Creating, Copying, Moving, or Deleting a Directory 12.11 Manipulating Directory Attributes 12.12 Renaming a Directory 12.13 Searching for Directories or Files Using Wildcards 12.14 Obtaining the Directory Tree 12.15 Parsing a Path 12.16 Parsing Paths in Environment Variables 12.17 Verifying a Path 12.18 Using a Temporary File in Your Application 12.19 Opening a File Stream with Just a File Handle 12.20 Writing to Multiple Output Files at One Time 12.21 Launching and Interacting with Console Utilities 12.22 Locking Subsections of a File 12.23 Watching the Filesystem for Specific Changes to One or More Files or Directories 12.24 Waiting for an Action to Occur in the Filesystem 12.25 Comparing Version Information of Two Executable Modules 12.26 Querying Information for All Drives on a System 12.27 Encrypting/Decrypting an Existing File 12.28 Compressing and Decompressing Your Files 13. Reflection 13.1 Listing Referenced Assemblies 13.2 Listing Exported Types 13.3 Finding Overridden Methods 13.4 Finding Members in an Assembly 13.5 Finding Members Within an Interface 13.6 Determining and Obtaining Nested Types Within an Assembly 13.7 Displaying the Inheritance Hierarchy for a Type 13.8 Finding the Subclasses of a Type 13.9 Finding All Serializable Types Within an Assembly 13.10 Filtering Output When Obtaining Members 13.11 Dynamically Invoking Members 13.12 Providing Guidance to Obfuscators 13.13 Determining if a Type or Method Is Generic 13.14 Reading Manifest Resources Programmatically 13.15 Accessing Local Variable Information 13.16 Creating a Generic Type 14. Web 14.1 Converting an IP Address to a Hostname 14.2 Converting a Hostname to an IP Address 14.3 Parsing a URI 14.4 Forming and Validating an Absolute URI 14.5 Handling Web Server Errors 14.6 Communicating with a Web Server 14.7 Going Through a Proxy 14.8 Obtaining the HTML from a URL 14.9 Using the New Web Browser Control 14.10 Tying Database Tables to the Cache 14.11 Caching Data with Multiple Dependencies 14.12 Prebuilding an ASP.NET Web Site Programmatically 14.13 Escaping and Unescaping Data for the Web 14.14 Using the UriBuilder Class 14.15 Inspect and Change Your Web Application Configuration 14.16 Working with HTML 14.17 Using Cached Results When Working with HTTP for Faster Performance 14.18 Checking out a Web Server's Custom Error Pages 14.19 Determining the Application Mappings for 18. Threading and Synchronization 18.1 Creating Per-Thread Static Fields 18.2 Providing Thread-Safe Access to Class Members 18.3 Preventing Silent Thread Termination 18.4 Polling an Asynchronous Delegate 18.5 Timing Out an Asynchronous Delegate 18.6 Being Notified of the Completion of an Asynchronous Delegate 18.7 Determining Whether a Request for a Pooled Thread Will be Queued 18.8 Configuring a Timer 18.9 Storing Thread-Specific Data Privately 18.10 Granting Multiple Access to Resources with a Semaphore 18.11 Synchronizing Multiple Processes with the Mutex 18.12 Using Events to Make Threads Cooperate 18.13 Get the Naming Rights for Your Events 18.14 Performing Atomic Operations Among Threads 19. Unsafe Code 19.1 Controlling Changes to Pointers Passed to Methods 19.2 Comparing Pointers 19.3 Navigating Arrays 19.4 Manipulating a Pointer to a Fixed Array 19.5 Returning a Pointer to a Particular Element in an Array 19.6 Creating and Using an Array of Pointers 19.7 Switching Unknown Pointer Types 19.8 Converting a String to a char* 19.9 Declaring a Fixed-Size Structure with an Embedded Array 20. Toolbox 20.1 Dealing with Operating System Shutdown, Power Management, or User Session Changes 20.2 Controlling a Service 20.3 List What Processes an Assembly Is Loaded In 20.4 Using Message Queues on a Local Workstation 20.5 Finding the Path to the Current Framework Version 20.6 Determining the Versions of an Assembly That Are Registered in the Global Assembly Cache (GAC) 20.7 Getting the Windows Directory 20.8 Capturing Output from the Standard Output Stream 20.9 Running Code in Its Own AppDomain 20.10 Determining the Operating System and Service Pack Version of the Current Operating System Index
Responsibility: Jay Hilyard and Stephen Teilhet.
More information:

Reviews

User-contributed reviews
Retrieving GoodReads reviews...
Retrieving DOGObooks reviews...

Tags

Be the first.
Confirm this request

You may have already requested this item. Please select Ok if you would like to proceed with this request anyway.

Linked Data


Primary Entity

<http://www.worldcat.org/oclc/71954661> # C♯ cookbook
    a schema:Book, schema:CreativeWork ;
   library:oclcnum "71954661" ;
   library:placeOfPublication <http://experiment.worldcat.org/entity/work/data/9304747#Place/beijing> ; # Beijing
   library:placeOfPublication <http://id.loc.gov/vocabulary/countries/cc> ;
   library:placeOfPublication <http://experiment.worldcat.org/entity/work/data/9304747#Place/sebastopol_ca> ; # Sebastopol, CA
   schema:about <http://dewey.info/class/005.133/e22/> ;
   schema:about <http://experiment.worldcat.org/entity/work/data/9304747#Topic/c_sharp_programsprak> ; # C sharp (programspråk)
   schema:about <http://id.loc.gov/authorities/subjects/sh2001001705> ; # C# (Computer program language)
   schema:about <http://id.worldcat.org/fast/843284> ; # C♯ (Computer program language)
   schema:bookEdition "2nd ed." ;
   schema:bookFormat bgn:PrintBook ;
   schema:contributor <http://viaf.org/viaf/29763887> ; # Stephen Teilhet
   schema:copyrightYear "2006" ;
   schema:creator <http://viaf.org/viaf/72455575> ; # Jay Hilyard
   schema:datePublished "2006" ;
   schema:exampleOfWork <http://worldcat.org/entity/work/id/9304747> ;
   schema:inLanguage "en" ;
   schema:name "C♯ cookbook"@en ;
   schema:productID "71954661" ;
   schema:publication <http://www.worldcat.org/title/-/oclc/71954661#PublicationEvent/beijing_sebastopol_ca_o_reilly_2006> ;
   schema:publisher <http://experiment.worldcat.org/entity/work/data/9304747#Agent/o_reilly> ; # O'Reilly
   schema:workExample <http://worldcat.org/isbn/9780596100636> ;
   wdrs:describedby <http://www.worldcat.org/title/-/oclc/71954661> ;
    .


Related Entities

<http://experiment.worldcat.org/entity/work/data/9304747#Topic/c_sharp_programsprak> # C sharp (programspråk)
    a schema:Intangible ;
   schema:name "C sharp (programspråk)"@en ;
    .

<http://id.loc.gov/authorities/subjects/sh2001001705> # C# (Computer program language)
    a schema:Intangible ;
   schema:name "C# (Computer program language)"@en ;
    .

<http://id.worldcat.org/fast/843284> # C♯ (Computer program language)
    a schema:Intangible ;
   schema:name "C♯ (Computer program language)"@en ;
    .

<http://viaf.org/viaf/29763887> # Stephen Teilhet
    a schema:Person ;
   schema:familyName "Teilhet" ;
   schema:givenName "Stephen" ;
   schema:name "Stephen Teilhet" ;
    .

<http://viaf.org/viaf/72455575> # Jay Hilyard
    a schema:Person ;
   schema:familyName "Hilyard" ;
   schema:givenName "Jay" ;
   schema:name "Jay Hilyard" ;
    .

<http://worldcat.org/isbn/9780596100636>
    a schema:ProductModel ;
   schema:isbn "0596100639" ;
   schema:isbn "9780596100636" ;
    .


Content-negotiable representations

Close Window

Please sign in to WorldCat 

Don't have an account? You can easily create a free account.