2004 ms c sharp programmers cookbook

900 92 0
2004   ms   c sharp programmers cookbook

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

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

C# Programmer's Cookbook ISBN:0735619301 by Allen Jones Microsoft Press © 2004 This book offers 226 code recipes applicable to a variety of difficulties that may arise in the process of application development Topics covered include XML processing, Windows forms, database access, networking, runtime security, cryptography and more Table of Contents C# Programmer's Cookbook Introduction Chapter 1 - Application Development Chapter 2 - Working with Data Application Domains, Reflection, and Chapter 3 Metadata Chapter 4 - Threads, Processes, and Synchronization Chapter 5 - XML Processing Chapter 6 - Windows Forms Chapter 7 - ASP.NET and Web Forms Chapter 8 - Graphics, Multimedia, and Printing Chapter 9 - Files, Directories, and I/O Chapter 10 - Database Access Chapter 11 - Networking and Internetworking Chapter 12 - XML Web Services and Remoting Chapter 13 - Runtime Security Chapter 14 - Cryptography Chapter 15 - Unmanaged Code Interoperability Chapter 16 - Commonly Used Interfaces and Patterns Chapter 17 - Windows Integration Index List of Figures List of Tables Back Cover Next time you hit the wall with a tough C# development problem, get the code behind the solution —and solve it the right way The C# Programmer’s Cookbook provides at-a-glance reference to hundreds of C# and Microsoft NET Framework programming scenarios using a concise, problem/solution format The book’s organized so you can quickly zero in on the topics and answers you need—with practical examples, code snippets, best practices, and undocumented secrets to get the job done No half-baked solutions Get expert code from expert developers Get hundreds of recipes covering every application type—from Microsoft Windows to Web pages, Web services, Windows Forms, and Windows services Discover expert ways to solve common Web application and network programming challenges Manage files, directories, and streams with the NET I/O classes Access databases using Microsoft ADO.NET Tackle advanced techniques for multithreading, manipulating XML data, NET Remoting, and reusing common patterns Develop rich multimedia applications using the .NET Framework Help protect your applications with code access security, role-based security, and cryptography Interoperate with legacy Win32 API and COMbased solutions About the Author Allen Jones is coauthor of the popular C# for Java Developers, Microsoft NET XML Web Services Step by Step, and Programming NET Security A 13-year technology veteran, he is known for the depth of his C# and NET expertise He specializes in developing and implementing enterprise solutions, including ecommerce and security systems C# Programmer's Cookbook Allen Jones Microsoft For Brenda PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2004 by Allen Jones and Matthew MacDonald All rights reserved No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher Library of Congress Cataloging-in-Publication Data [pending.] Printed and bound in the United States of America 1 2 3 4 5 6 7 8 9 QWT 8 7 6 5 4 3 Distributed in Canada by H.B Fenn and Company Ltd A CIP catalogue record for this book is available from the British Library Microsoft Press books are available through booksellers and distributors worldwide For further information about international editions, contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329 Visit our Web site at www.microsoft.com/mspress Send comments to mspinput@microsoft.com Active Directory, ActiveMovie, ActiveX, Authenticode, DirectShow, DirectX, Microsoft, Microsoft Press, MSDN, Visual Studio, Win32, Windows, the Windows logo, Windows Media, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries Other product and company names mentioned herein may be the trademarks of their respective owners The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred Acquisitions Editor: Danielle Bird Voeller Project Editor: Dick Brown and Denise Bankaitis Technical Editor: Eric Dettinger Body Part No X10-08418 Allen Jones Allen Jones is coauthor of the popular C# for Java Developers and Microsoft NET XML Web Services Step by Step (Microsoft Press) A 13year technology veteran, he is known for the depth of his C# and NET expertise Allen specializes in developing and implementing enterprise solutions, including e- commerce and security systems Introduction Overview Mastering the development of Microsoft NET Framework applications in C# is less about knowing the C# language and more about knowing how to use the functionality of the NET Framework class library most effectively The C# Programmer's Cookbook explores the breadth of the NET Framework class library and provides specific solutions to common and interesting programming problems Each solution (or recipe) is presented in a succinct problem/solution format and is accompanied by working code samples The C# Programmer's Cookbook is not intended to teach you how to program, nor to teach you C# However, if you have even the most rudimentary experience programming applications built on the NET Framework using C#, you will find this book to be an invaluable resource Ideally, when you are facing a problem, this book will contain a recipe that provides the solution—or at least it will point you in the right direction Even if you are simply looking to broaden your knowledge of the NET Framework class library, the C# Programmer's Cookbook is the perfect resource to assist you You cannot become proficient with C# and the classes in the NET Framework class library merely by reading about them; you must use them and experiment with them by writing programs, programs, and more programs The structure and content of this book and the real-world applicability of the solutions it provides offer the perfect starting point from which to kick-start your own experimentation Note The code in this book has been written for and tested on version 1.1 of the NET Framework In many cases, you will find that the sample code will run on version 1.0 of the NET Framework, but this has not been tested and no guarantees are made Code Samples The code for all recipes in the C# Programmer's Cookbook is available online at http://microsoft.com/mspress/books/6456.asp To download the sample files, click the Companion Content link in the More Information menu on the right side of the page This action loads the Companion Content page, which includes a link for downloading the sample files To install the sample files, click the Download The Book's Sample Files link and follow the instructions in the setup program A link to the sample code will be added to your Start menu The code is provided as a set of Visual Studio NET 2003 solutions and projects organized by chapter and recipe number Each chapter is a separate solution, and each recipe is a separate project within the chapter's solution Some recipes in Chapter 11 and Chapter 12 that demonstrate network programming include separate projects that contain the client and server elements of the recipe's solution Although all samples are provided as Visual Studio NET projects, most consist of a single source file that you can compile and run independent of Visual Studio NET If you are not using Visual Studio NET 2003 you can locate the code for a particular recipe by navigating through the directory structure of the sample code For example, to find the code for recipe 4.3, you would look up the code in the directory "Chapter04\Recipe04-03" If you use the command-line compiler, ensure that you include references to all required NET class library assemblies Some of the sample applications require command-line arguments Where required, the recipe's text will describe the arguments If you are using Visual Studio NET, you can enter these arguments in the project properties (under the Debugging node of the Configuration Properties item) Keep in mind that if you need to enter directory or file names that incorporate spaces, you will need to place the full name in quotation marks Some additional steps are required to install the two virtual directories used for the examples that accompany Chapter 7, "ASP.NET and Web Forms," and Chapter 12, "XML Web Services and Remoting." These steps are described in a readme.txt file provided with the downloaded code and on the code download page Chapter 12: XML Web Services and Remoting Figure 12.1: Configuring a dynamic XML Web service URL Figure 12.2: Monitoring a failed transaction Figure 12.3: Using a remotable class Chapter 17: Windows Integration Figure 17.1: The Windows Service Start Failure message box List of Tables Chapter 1: Application Development Table 1.1: Logical Operators Supported by the #if #endif Directive Table 1.2: Commonly Used Switches of the File Signing Tool Table 1.3: Commonly Used Switches of the Certificate Creation Tool Chapter 2: Working with Data Table 2.1: Character Encoding Classes Table 2.2: Commonly Used Regular Expression Metacharacter Elements Table 2.3: Commonly Used Regular Expressions Table 2.4: Operators Supported by the DateTime and TimeSpan Chapter 3: Application Domains, Reflection, and Metadata Table 3.1: Commonly Used AppDomainSetup Properties Table 3.2: Methods That Return Type Objects Table 3.3: Members of the AttributeUsage Enumeration Chapter 4: Threads, Processes, and Synchronization Table 4.1: Controlling the Execution of a Thread Table 4.2: WaitHandle Methods for Synchronizing Thread Execution Table 4.3: Properties of the ProcessStartInfo Class Table 4.4: Methods for Obtaining Process References Chapter 5: XML Processing Table 5.1: XPath Expression Syntax Chapter 7: ASP.NET and Web Forms Table 7.1: Types of State Management Table 7.2: Types of Authentication Chapter 9: Files, Directories, and I/O Table 9.1: Members for Files and Directories Table 9.2: Methods for Manipulating a FileInfo Object Table 9.3: Methods for Manipulating a DirectoryInfo Object Chapter 10: Database Access Table 10.1: NET Framework Data Provider Implementations Table 10.2: Connection String Settings That Control Connection Pooling Table 10.3: Common Command Object Properties Table 10.4: Parameter Properties Table 10.5: Commonly Used Members of Data Reader Classes Chapter 13: Runtime Security Table 13.1: Evidence Classes That Generate Identity Permissions Table 13.2: Classes and Their Methods That Allow You to Assign Evidence to an Assembly Table 13.3: Windows Built-In Account Names and Identifiers Table 13.4: Members of the PrincipalPolicy Enumeration Chapter 14: Cryptography Table 14.1: Hashing Algorithm Implementations Table 14.2: Keyed Hashing Algorithm Implementations Table 14.3: Symmetric Algorithm Implementations Table 14.4: Operation of a CryptoStream Object Chapter 16: Commonly Used Interfaces and Patterns Table 16.1: Members of the IEnumerator Interface Chapter 17: Windows Integration Table 17.1: Commonly Used Members of the Environment Class Table 17.2: Determining the Current Operating System Table 17.3: Static Fields of the Registry Class Table 17.4: RegistryKey Methods to Create, Read, Update, and Delete Registry Keys and Values Table 17.5: Methods That Control the Operation of a Service ... For further information about international editions, contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329 Visit our Web site at www.microsoft.com/mspress Send comments to mspinput@microsoft.com... WriteString("Welcome to the C# Programmer's Cookbook, " } } To build the ConsoleUtils class into a Console application named ConsoleUtils.exe, use the command csc /target:exe ConsoleUtils.cs You can run the resulting executable assembly directly from the... However, the C# compiler can't compile your Microsoft Visual Basic NET or COBOL NET code for inclusion in your assembly You must first use a languagespecific compiler to turn your source into MSIL in a structure that

Ngày đăng: 25/03/2019, 17:12

Từ khóa liên quan

Mục lục

  • Table of Contents

  • BackCover

  • C# Programmer's Cookbook

  • Introduction

    • Code Samples

    • System Requirements

    • Other Books

    • Microsoft Press Support

    • Chapter 1: Application Development

      • 1.1 Create a Console Application

      • 1.2 Create a Windows-Based Application

      • 1.3 Create and Use a Code Module

      • 1.4 Create and Use a Code Library

      • 1.5 Access Command-Line Arguments

      • 1.6 Selectively Include Code at Build Time

      • 1.7 Access a Program Element That Has the Same Name as a Keyword

      • 1.8 Create and Manage Strong-Named Key Pairs

      • 1.9 Give an Assembly a Strong Name

      • 1.10 Verify That a Strong-Named Assembly Has Not Been Modified

      • 1.11 Delay Sign an Assembly

      • 1.12 Sign an Assembly with an Authenticode Digital Signature

      • 1.13 Create and Trust a Test Software Publisher Certificate

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan