1. Trang chủ
  2. » Công Nghệ Thông Tin

a0073 c cookboo morebook vn 2756

7 4 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề C# Cookbook
Tác giả Jay Hilyard, Stephen Teilhet
Thể loại Cookbook
Năm xuất bản 2004
Định dạng
Số trang 7
Dung lượng 1,87 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Finding All Occurrences of a Character Within a String Recipe 2.5.. Inserting Text into a String Recipe 2.10.. Removing or Replacing Characters Within a String Recipe 2.11.. Convertin

Trang 1

[ Team LiB ]

• Table of Contents

• Reader Reviews

C# Cookbook

By Jay Hilyard, Stephen Teilhet

Publisher: O'Reilly

Pub Date: January 2004

ISBN: 0-596-00339-0

Pages: 800

The C# Cookbook offers a definitive collection of solutions and examples for this new programming

language Recipes range from simple tasks to the more complex, and are organized with respect to the types of problems you'll need to solve as you progress in your experience as a C# programmer Nearly every recipe contains a complete, documented code sample showing you how to solve the specific problem, as well as a discussion of how the underlying technology works and a discussion of alternatives, limitations, and other considerations where appropriate.

[ Team LiB ]

Trang 2

[ Team LiB ]

• Table of Contents

• Reader Reviews

C# Cookbook

By Jay Hilyard, Stephen Teilhet

Publisher: O'Reilly

Pub Date: January 2004

ISBN: 0-596-00339-0

Pages: 800

Dedication

Copyright

Preface

Who This Book Is For

What You Need to Use This Book

How This Book Is Organized

What Was Left Out

Conventions Used in This Book

About the Code

Using Code Examples

Platform Notes

Comments and Questions

Acknowledgments

Chapter 1 Numbers

Recipe 1.1 Determining Approximate Equality Between a Fraction and Floating-Point Value

Recipe 1.2 Converting Degrees to Radians

Recipe 1.3 Converting Radians to Degrees

Recipe 1.4 Using the Bitwise Complement Operator with Various Data Types

Recipe 1.5 Test for an Even or Odd Value

Recipe 1.6 Obtaining the Most- or Least-Significant Bits of a Number

Trang 3

Recipe 1.7 Converting a Number in Another Base to Base10

Recipe 1.8 Determining Whether a String Is a Valid Number

Recipe 1.9 Rounding a Floating-Point Value

Recipe 1.10 Different Rounding Algorithms

Recipe 1.11 Converting Celsius to Fahrenheit

Recipe 1.12 Converting Fahrenheit to Celsius

Recipe 1.13 Safely Performing a Narrowing Numeric Cast

Recipe 1.14 Finding the Length of Any Three Sidesof a Right Triangle

Recipe 1.15 Finding the Angles of a Right Triangle

Chapter 2 Strings and Characters

Recipe 2.1 Determining the Kind of Character

Recipe 2.2 Determining Whether a Character Is Within a Specified Range

Recipe 2.3 Controlling Case Sensitivity when Comparing Two Characters

Recipe 2.4 Finding All Occurrences of a Character Within a String

Recipe 2.5 Finding the Location of All Occurrencesof a String Within Another String

Recipe 2.6 The Poor Man's Tokenizer

Recipe 2.7 Controlling Case Sensitivity when Comparing Two Strings

Recipe 2.8 Comparing a String to the Beginning or End of a Second String

Recipe 2.9 Inserting Text into a String

Recipe 2.10 Removing or Replacing Characters Within a String

Recipe 2.11 Encoding Binary Data as Base64

Recipe 2.12 Decoding a Base64-Encoded Binary

Recipe 2.13 Converting a String Returned as a Byte[ ] Back into a String

Recipe 2.14 Passing a String to a Method that Accepts Only a Byte[ ]

Recipe 2.15 Converting Strings to Their Equivalent Value Type

Recipe 2.16 Formatting Data in Strings

Recipe 2.17 Creating a Delimited String

Recipe 2.18 Extracting Items from a Delimited String

Recipe 2.19 Setting the Maximum Number of Characters a String Can Contain

Recipe 2.20 Iterating Over Each Character in a String

Recipe 2.21 Improving String Comparison Performance

Recipe 2.22 Improving StringBuilder Performance

Recipe 2.23 Pruning Characters from the Headand/or Tail of a String

Chapter 3 Classes and Structures

Recipe 3.1 Creating Union-Type Structures

Recipe 3.2 Allowing a Type to Represent Itself as a String

Recipe 3.3 Converting a String Representation of an Object into an Actual Object

Recipe 3.4 Polymorphism via Concrete or Abstract Base Classes

Recipe 3.5 Making a Type Sortable

Recipe 3.6 Making a Type Searchable

Recipe 3.7 Indirectly Overloading the +=, -=, /=, and *= Operators

Recipe 3.8 Indirectly Overloading the &&, ||, and ?: Operators

Recipe 3.9 Improving the Performance of a Structure's Equals Method

Recipe 3.10 Turning Bits On or Off

Recipe 3.11 Making Error-Free Expressions

Recipe 3.12 Minimizing (Reducing) Your Boolean Logic

Recipe 3.13 Converting Between Simple Types in a Language Agnostic Manner

Recipe 3.14 Determining Whether to Use theCast Operator, the as Operator, or theis Operator

Trang 4

Recipe 3.15 Casting with the as Operator

Recipe 3.16 Determining a Variable's Type with the is Operator

Recipe 3.17 Polymorphism via Interfaces

Recipe 3.18 Calling the Same Method on Multiple Object Types

Recipe 3.19 Adding a Notification Callback Using an Interface

Recipe 3.20 Using Multiple Entry Points toVersion an Application

Recipe 3.21 Preventing the Creation of an Only Partially Initialized Object

Recipe 3.22 Returning Multiple Items from a Method

Recipe 3.23 Parsing Command-Line Parameters

Recipe 3.24 Retrofitting a Class to Interoperate with COM

Recipe 3.25 Initializing a Constant Field at Runtime

Recipe 3.26 Writing Code that Is Compatible with the Widest Range of Managed Languages

Recipe 3.27 Implementing Nested foreach Functionality in a Class

Recipe 3.28 Building Cloneable Classes

Recipe 3.29 Assuring an Object's Disposal

Recipe 3.30 Releasing a COM Object ThroughManaged Code

Recipe 3.31 Creating an Object Cache

Recipe 3.32 The Single Instance Object

Recipe 3.33 Choosing a Serializer

Recipe 3.34 Creating Custom Enumerators

Recipe 3.35 Rolling Back Object Changes

Recipe 3.36 Disposing of Unmanaged Resources

Recipe 3.37 Determining Where Boxing and Unboxing Occur

Chapter 4 Enumerations

Recipe 4.1 Displaying an Enumeration Value as a String

Recipe 4.2 Converting Plain Text to an Equivalent Enumeration Value

Recipe 4.3 Testing for a Valid Enumeration Value

Recipe 4.4 Testing for a Valid Enumeration of Flags

Recipe 4.5 Using Enumerated Members in a Bitmask

Recipe 4.6 Determining Whether One or More Enumeration Flags Are Set

Chapter 5 Exception Handling

Recipe 5.1 Verifying Critical Parameters

Recipe 5.2 Indicating Where Exceptions Originate

Recipe 5.3 Choosing when to Throw a Particular Exception

Recipe 5.4 Handling Derived Exceptions Individually

Recipe 5.5 Assuring Exceptions are Not Lost when Using Finally Blocks

Recipe 5.6 Handling Exceptions Thrown from Methods Invoked via Reflection

Recipe 5.7 Debugging Problems whenLoading an Assembly

Recipe 5.8 HRESULT-Exception Mapping

Recipe 5.9 Handling User-Defined HRESULTs

Recipe 5.10 Preventing Unhandled Exceptions

Recipe 5.11 Displaying Exception Information

Recipe 5.12 Getting to the Root of a Problem Quickly

Recipe 5.13 Creating a New Exception Type

Recipe 5.14 Obtaining a Stack Trace

Recipe 5.15 Breaking on a First Chance Exception

Recipe 5.16 Preventing the Nefarious TypeInitializationException

Recipe 5.17 Handling Exceptions Thrown from an Asynchronous Delegate

Trang 5

Chapter 6 Diagnostics

Recipe 6.1 Controlling Tracing Output inProduction Code

Recipe 6.2 Providing Fine-Grained Control Over Debugging/Tracing Output

Recipe 6.3 Creating Your Own Custom Switch Class

Recipe 6.4 A Custom Trace Class that Outputs Information in an XML Format

Recipe 6.5 Conditionally Compiling Blocks of Code

Recipe 6.6 Determining Whether a Process Has Stopped Responding

Recipe 6.7 Using One or More Event Logs in Your Application

Recipe 6.8 Changing the Maximum Size of a Custom Event Log

Recipe 6.9 Searching Event Log Entries

Recipe 6.10 Watching the Event Log for a Specific Entry

Recipe 6.11 Finding All Sources Belonging to a Specific Event Log

Recipe 6.12 Implementing a Simple Performance Counter

Recipe 6.13 Implementing Performance Counters that Require a Base Counter

Recipe 6.14 Enable/Disable Complex Tracing Code

Chapter 7 Delegates and Events

Recipe 7.1 Controlling when and if a Delegate Fires Within a Multicast Delegate

Recipe 7.2 Obtaining Return Values from Each Delegate in a Multicast Delegate

Recipe 7.3 Handling Exceptions Individually for Each Delegate in a Multicast Delegate

Recipe 7.4 Converting a Synchronous Delegate to an Asynchronous Delegate

Recipe 7.5 Adding Events to a Sealed Class

Recipe 7.6 Passing Specialized Parameters to and from an Event

Recipe 7.7 An Advanced Interface Search Mechanism

Recipe 7.8 An Advanced Member Search Mechanism

Recipe 7.9 Observing Additions and Modifications to a Hashtable

Recipe 7.10 Using the Windows Keyboard Hook

Recipe 7.11 Using Windows Hooks to Manipulate the Mouse

Chapter 8 Regular Expressions

Recipe 8.1 Enumerating Matches

Recipe 8.2 Extracting Groups from a MatchCollection

Recipe 8.3 Verifying the Syntax of a Regular Expression

Recipe 8.4 Quickly Finding Only the Last Match in a String

Recipe 8.5 Replacing Characters or Words in a String

Recipe 8.6 Augmenting the Basic String Replacement Function

Recipe 8.7 A Better Tokenizer

Recipe 8.8 Compiling Regular Expressions

Recipe 8.9 Counting Lines of Text

Recipe 8.10 Returning the Entire Line in Which a Match Is Found

Recipe 8.11 Finding a Particular Occurrence of a Match

Recipe 8.12 Using Common Patterns

Recipe 8.13 Documenting Your Regular Expressions

Chapter 9 Collections

Recipe 9.1 Swapping Two Elements in an Array

Recipe 9.2 Quickly Reversing an Array

Recipe 9.3 Reversing a Two-Dimensional Array

Recipe 9.4 Reversing a Jagged Array

Trang 6

[ Team LiB ]

[SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z]

zip code, regular expression patterns for

[ Team LiB ]

Trang 7

Brought to You by

Like the book? Buy it!

Ngày đăng: 04/12/2022, 09:31

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w