How This Book Is Organized


This book is organized into 20 chapters, each of which focuses on a particular topic in creating C# solutions. The following paragraphs summarize each chapter to give you an overview of this book's contents:


Chapter 1, Numbers and Enumerations

This chapter focuses on the numeric and enumeration data types used in C# code. Recipes cover such things as numeric conversions, using bitwise operators on numbers, and testing strings to determine whether they contain a numeric value. The display, conversion, and testing of enumeration types and recipes on using enumerations that consist of bit flags are also shown.


Chapter 2, Strings and Characters

This chapter covers both the String and Char data types. Various recipes show how to compare strings in various ways, encode/decode strings, break strings apart, and put them back together again, to name a few.


Chapter 3, Classes and Structures

This large chapter contains recipes dealing with both class and structure data types. This chapter covers a wide range of recipes from design patterns to converting a class to interoperating with COM.


Chapter 4, Generics

This is a new chapter focusing on the new generics capacity in C#, which allows you to have code operate uniformly on values of different types. There are recipes to help your general understanding of generics as well as when they are appropriate to use, what support is provided in the Framework for them, and how to create custom implementations of collections using generics.


Chapter 5, Collections

This chapter examines recipes that make use of collections. The collection recipes make use ofas well as extend the functionality ofthe array (single, multi, and jagged), the List<T>, and the Hashtable. The new generic-based collections are explored, and the various ways to create your own strongly typed collection are also discussed.


Chapter 6, Iterators and Partial Types

In this chapter, two of the new features of C# are used to solve very different programming problems. We show how you can implement iterators for generic and nongeneric types and implement foreach functionality using iterators, as well as custom iterator implementations. The other feature of C# in this chapter is partial types. We show how you can use partial types to do things like better segment your code and how to generate code that is more easily extensible.


Chapter 7, Exception Handling

The recipes in this chapter focus on the best ways to implement exception handling in your application. Preventing unhandled exceptions, reading and displaying stack traces, and throwing/rethrowing exceptions are included recipes. In addition, specific recipes show how to overcome some tricky situations, such as exceptions from late-bound called methods, and how to build a custom exception visualizer for the debugger.


Chapter 8, Diagnostics

This chapter explores recipes that use data types that fall under the System.Diagnostics namespace. Recipes deal with the trace/Debug classes, event logs, processes, performance counters, and custom debugger displays for your types.


Chapter 9, Delegates, Events, and Anonymous Methods

This chapter's recipes show how delegates, events, and anonymous methods can be used in your applications. Recipes allow manipulation of delegates that call more than one method, synchronous delegates, asynchronous delegates, and Windows keyboard hooks. Anonymous methods are explored and recipes show their usage in place of old-style delegates as well as their use in implementing closures and functors.


Chapter 10, Regular Expressions

This chapter covers a very useful set of classes that are used to run regular expressions against strings. Recipes enumerate regular expression matches, break up strings into tokens, find/replace characters, and verify the syntax of a regular expression. A recipe is also included that contains many common regular expression patterns.


Chapter 11, Data Structures and Algorithms

This chapter goes a bit outside of what is provided for you in the .NET Framework Class Library and implements certain data structures and algorithms that are not in the FCL, or possibly are not in existence exactly the way you would like to use them, but ones that you have used to solve problems before. Items such as queues, maps, trees, and hashes are explored.


Chapter 12, Filesystem I/O

This chapter deals with filesystem interactions in four distinct ways. The first way is to look at typical file interactions; the second way looks at directory-or folder-based interactions; the third way deals with paths and temporary files; and the fourth way deals with advanced filesystem I/O topics.


Chapter 13, Reflection

This chapter shows ways to use the built-in assembly inspection system provided by the .NET Framework to determine what types, interfaces, and methods are implemented within an assembly and how to access them in a late-bound fashion.


Chapter 14, Web

This chapter covers accessing a web site and its content as well as programmatically determining web site configuration. Among the recipes in this chapter are using the new web browser control and setting up caching triggers to refresh cached data when a database table changes.


Chapter 15, XML

If you use .NET, it is likely that you will be dealing with XML to one degree or another; in this chapter, we explore some of the uses for XML, including XPath and XSLT, and topics such as the validation of XML and transformation of XML to HTML.


Chapter 16, Networking

This chapter explores the connectivity options provided by the .NET Framework and how to programmatically access network resources. Recipes for using TCP/IP directly, named pipes for communication, building your own port scanner, and more are covered here.


Chapter 17, Security

There are many ways to write secure code and protect data using the .NET Framework, and in this chapter, we explore areas such as controlling access to types, encryption and decryption, random numbers, securely storing data, and using programmatic and declarative security.


Chapter 18, Threading and Synchronization

This chapter addresses the subject of using multiple threads of execution in a .NET program and issues like how to implement threading in your application, protecting resources from and allowing safe concurrent access, storing per-thread data, and the use of asynchronous delegates for processing.


Chapter 19, Unsafe Code

This chapter discusses how C# allows you to step outside of the safe environment of managed code and write code that is considered unsafe by the .NET Framework. The possibilities and restrictions of using unsafe code in C# are addressed by illustrating solutions to problems using unsafe code.


Chapter 20, Toolbox

This chapter has recipes for those random sorts of operations that developers run into over and over again, like determining locations of system resources, sending email, and working with services. It also covers some less frequently accessed but helpful application pieces like message queuing, running code in a separate AppDomain, and finding the versions of assemblies in the GAC.

In some cases, certain recipes are related. In these cases, the See Also section of the recipe as well as some text in the Discussion will note the relationships.



C# Cookbook
Secure Programming Cookbook for C and C++: Recipes for Cryptography, Authentication, Input Validation & More
ISBN: 0596003943
EAN: 2147483647
Year: 2004
Pages: 424

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net