1321 visual c 2010 recipes

1K 265 0
1321 visual c 2010 recipes

Đ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

... name : "); // Welcome the reader to Visual C# 2010 Recipes WriteString("Welcome to Visual C# 2010 Recipes, " + name); } } } The HelloWorld class listed next uses the ConsoleUtils class to display... presented in a succinct problem/solution format, and most are accompanied by working code samples Visual C# 2010 Recipes is not intended to teach you how to program, nor to teach you C# However, if... • Use the C# command-line compiler to build console and Windows Forms applications (recipes 1-1 and 1-2) • Create and use code modules and libraries (recipes 1-3 and 1-4) • Access command-line

Ngày đăng: 11/07/2018, 16:59

Mục lục

  • APRess - Visual C# 2010 Recipes (03-2010) (ATTiCA)

  • Contents at a Glance

  • Contents

  • About the Authors

  • About the Technical Reviewer

  • Acknowledgments

  • Introduction

  • Application Development

    • 1-1. Create a Console Application from the Command Line

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 1-2. Create a Windows-Based Application from the Command Line

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 1-3. Create and Use a Code Module

      • Problem

      • Solution

      • How It Works

      • Usage

    • 1-4. Create and Use a Code Library from the Command Line

      • Problem

      • Solution

      • How It Works

      • Usage

    • 1-5. Access Command-Line Arguments

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 1-6. Include Code Selectively at Build Time

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

      • Notes

    • 1-7. Access a Program Element That Has the Same Name As a Keyword

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-8. Create and Manage Strongly Named Key Pairs

      • Problem

      • Solution

      • How It Works

    • 1-9. Give an Assembly a Strong Name

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 1-10. Verify That a Strongly Named Assembly Has Not Been Modified

      • Problem

      • Solution

      • How It Works

    • 1-11. Delay-Sign an Assembly

      • Problem

      • Solution

      • How It Works

    • 1-12. Sign an Assembly with an Authenticode Digital Signature

      • Problem

      • Solution

      • How It Works

      • Usage

    • 1-13. Create and Trust a Test Software Publisher Certificate

      • Problem

      • Solution

      • How It Works

    • 1-14. Manage the Global Assembly Cache

      • Problem

      • Solution

      • How It Works

    • 1-15. Prevent People from Decompiling Your Code

      • Problem

      • Solution

      • How It Works

    • 1-16. Manipulate the Appearance of the Console

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-17. Create a Static Class

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-18. Create an Anonymous Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-19. Create an ExpandoObject Dynamic Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-20. Define an Automatically Implemented Property

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-21. Overload an Operator

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-22. Define a Conversion Operator

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-23. Handle an Event with an Anonymous Function

      • Problem

      • Solution

      • How It Works

      • The Code

    • 1-24. Implement a Custom Indexer

      • Problem

      • Solution

      • How It Works

      • The Code

  • Data Manipulation

    • 2-1. Manipulate the Contents of a String Efficiently

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-2. Encode a String Using Alternate Character Encoding

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

      • Notes

    • 2-3. Convert Basic Value Types to Byte Arrays

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-4. Base64 Encode Binary Data

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-5. Validate Input Using Regular Expressions

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

      • Notes

    • 2-6. Use Compiled Regular Expressions

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-7. Create Dates and Times from Strings

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-8. Add, Subtract, and Compare Dates and Times

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-9. Sort an Array or a Collection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-10. Copy a Collection to an Array

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-11. Use a Strongly Typed Collection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-12. Create a Generic Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-13. Store a Serializable Object to a File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-14. Serialize an Object Using JSON

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-15. Read User Input from the Console

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-16. Using Large Integer Values

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-17. Select Collection or Array Elements

      • Problem

      • Solution

      • How It Works

      • The Code

    • 2-18. Remove Duplicate Items from an Array or Collection

      • Problem

      • Solution

      • How It Works

      • The Code

  • Application Domains, Reflection, and Metadata

    • 3-1. Create an Application Domain

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-2. Create Types That Can Be Passed Across Application Domain Boundaries

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-3. Avoid Loading Unnecessary Assemblies into Application Domains

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-4. Create a Type That Cannot Cross Application Domain Boundaries

      • Problem

      • Solution

      • How It Works

    • 3-5. Load an Assembly into the Current Application Domain

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-6. Execute an Assembly in a Different Application Domain

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 3-7. Instantiate a Type in a Different Application Domain

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-8. Pass Data Between Application Domains

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-9. Unload Assemblies and Application Domains

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-10. Retrieve Type Information

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-11. Test an Object’s Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-12. Instantiate an Object Using Reflection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-13. Create a Custom Attribute

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 3-14. Inspect the Attributes of a Program Element Using Reflection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-15. Programmatically Discover the Members of a Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-16. Invoke a Type Member Using Reflection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-17. Dynamically Invoke a Type Member

      • Problem

      • Solution

      • How It Works

      • The Code

    • 3-18. Create a Custom Dynamic Type

      • Problem

      • Solution

      • How It Works

      • The Code

  • Threads, Processes, and Synchronization

    • 4-1. Execute a Method Using the Thread Pool

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 4-2. Execute a Method Asynchronously

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-3. Execute a Method Periodically

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-4. Execute a Method at a Specific Time

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-5. Execute a Method by Signaling a WaitHandle Object

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-6. Execute a Method Using a New Thread

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-7. Synchronize the Execution of Multiple Threads Using a Monitor

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-8. Synchronize the Execution of Multiple Threads Using an Event

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-9. Synchronize the Execution of Multiple Threads Using a Mutex

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-10. Synchronize the Execution of Multiple Threads Using a Semaphore

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-11. Synchronize Access to a Shared Data Value

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-12. Know When a Thread Finishes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-13. Terminate the Execution of a Thread

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-14. Create a Thread-Safe Collection Instance

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-15. Start a New Process

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-16. Terminate a Process

      • Problem

      • Solution

      • How It Works

      • The Code

    • 4-17. Ensure That Only One Instance of an Application Can Execute Concurrently

      • Problem

      • Solution

      • How It Works

      • The Code

  • Files, Directories, and I/O

    • 5-1. Retrieve Information About a File, Directory, or Drive

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 5-2. Set File and Directory Attributes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-3. Copy, Move, or Delete a File or Directory

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-4. Calculate the Size of a Directory

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-5. Retrieve Version Information for a File

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 5-6. Show a Just-in-Time Directory Tree in the TreeView Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-7. Read and Write a Text File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-8. Read and Write a Binary File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-9. Read a File Asynchronously

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 5-10. Find Files That Match a Wildcard Expression

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-11. Test Two Files for Equality

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-12. Manipulate Strings Representing File Names

      • Problem

      • Solution

      • How It Works

    • 5-13. Determine If a Path Is a Directory or a File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-14. Work with Relative Paths

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 5-15. Create a Temporary File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-16. Get the Total Free Space on a Drive

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-17. Show the Common File Dialog Boxes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-18. Use an Isolated Store

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-19. Monitor the File System for Changes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-20. Access a COM Port

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-21. Get a Random File Name

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-22. Manipulate the Access Control List of a File or Directory

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-23. Compress Data

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-24. Log Data to a File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-25. Process a Log File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 5-26. Communicate Between Processes

      • Problem

      • Solution

      • How It Works

      • The Code

  • XML Processing

    • 6-1. Show the Structure of an XML Document in a TreeView

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 6-2. Insert Nodes in an XML Document

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-3. Quickly Append Nodes in an XML Document

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-4. Find Specific Elements by Name

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 6-5. Get XML Nodes in a Specific XML Namespace

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-6. Find Elements with an XPath Search

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 6-7. Read and Write XML Without Loading an Entire Document into Memory

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-8. Validate an XML Document Against a Schema

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-9. Use XML Serialization with Custom Objects

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-10. Create a Schema for a .NET Class

      • Problem

      • Solution

      • How It Works

      • Usage

    • 6-11. Generate a Class from a Schema

      • Problem

      • Solution

      • How It Works

      • Usage

    • 6-12. Perform an XSL Transform

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-13. Load XML with LINQ

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-14. Create a New XML Tree with LINQ

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-15. Query XML with LINQ

      • Problem

      • Solution

      • How It Works

      • The Code

    • 6-16. Modify an XML Tree with LINQ

      • The Problem

      • The Solution

      • How It Works

      • The Code

  • Windows Forms

    • 7-1. Add a Control Programmatically

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-2. Store Data with a Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-3. Process All the Controls on a Form

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-4. Track the Visible Forms in an Application

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 7-5. Find All MDI Child Forms

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-6. Save Configuration Settings for a Form

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-7. Force a List Box to Scroll to the Most Recently Added Item

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-8. Restrict a Text Box to Accept Only Specific Input

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 7-9. Use an Autocomplete Combo Box or Text Box

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-10. Sort a List View by Any Column

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-11. Lay Out Controls Automatically

      • Problem

      • Solution

      • How It Works

    • 7-12. Use Part of a Main Menu for a Context Menu

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-13. Make a Multilingual Form

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-14. Create a Form That Cannot Be Moved

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-15. Make a Borderless Form Movable

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-16. Create an Animated System Tray Icon

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-17. Validate an Input Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-18. Use a Drag-and-Drop Operation

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-19. Update the User Interface in a Multithreaded Application

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-20. Display a Web Page in a Windows-Based Application

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-21. Display WPF Windows in a Windows Forms Application

      • Problem

      • Solution

      • How It Works

      • The Code

    • 7-22. Display WPF Controls in Windows Forms

      • Problem

      • Solution

      • How It Works

      • The Code

  • Graphics, Multimedia, and Printing

    • 8-1. Find All Installed Fonts

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-2. Perform Hit Testing with Shapes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-3. Create an Irregularly Shaped Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-4. Create a Movable Sprite

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-5. Create a Scrollable Image

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-6. Perform a Screen Capture

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-7. Use Double Buffering to Increase Redraw Speed

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-8. Show a Thumbnail for an Image

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-9. Play a Simple Beep or System Sound

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-10. Play a WAV File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-11. Play a Sound File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-12. Play a Video

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-13. Retrieve Information About Installed Printers

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 8-14. Print a Simple Document

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-15. Print a Multipage Document

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-16. Print Wrapped Text

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-17. Show a Dynamic Print Preview

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-18. Manage Print Jobs

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-19. Perform Text-to-Speech

      • Problem

      • Solution

      • How It Works

      • The Code

    • 8-20. Recognize Characters in an Image (OCR)

      • Problem

      • Solution

      • How It Works

      • The Code

  • Database Access

    • 9-1. Connect to a Database

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-2. Use Connection Pooling

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 9-3. Create a Database Connection String Programmatically

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-4. Store a Database Connection String Securely

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-5. Execute a SQL Command or Stored Procedure

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-6. Use Parameters in a SQL Command or Stored Procedure

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-7. Process the Results of a SQL Query Using a Data Reader

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-8. Obtain an XML Document from a SQL Server Query

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-9. Perform Asynchronous Database Operations Against SQL Server

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-10. Write Database-Independent Code

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-11. Discover All Instances of SQL Server on Your Network

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-12. Create an In-Memory Cache

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-13. Create a DataSet Programmatically

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-14. Perform a LINQ Query

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-15. Perform a LINQ Query with Entity Types

      • Problem

      • Solution

      • How It Works

      • The Code

    • 9-16. Compare LINQ DataSet Results

      • Problem

      • Solution

      • How It Works

      • The Code

  • Networking

    • 10-1. Obtain Information About the Local Network Interface

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-2. Detect Changes in Network Connectivity

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-3. Download Data over HTTP or FTP

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 10-4. Download a File and Process It Using a Stream

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-5. Respond to HTTP Requests from Within Your Application

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-6. Get an HTML Page from a Site That Requires Authentication

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-7. Send E-mail Using SMTP

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-8. Resolve a Host Name to an IP Address

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 10-9. Ping an IP Address

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 10-10. Communicate Using TCP

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 10-11. Create a Multithreaded TCP Server That Supports Asynchronous Communications

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-12. Communicate Using UDP

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-13. Create a SOAP-Based Web Service

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-14. Call a WCF Service Using a Dynamically Generated Service Proxy

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-15. Process the Content of an Atom or RSS Feed

      • Problem

      • Solution

      • How It Works

      • The Code

    • 10-16. Manipulate URIs

      • Problem

      • Solution

      • How It Works

      • The Code

  • Security and Cryptography

    • 11-1. Allow Partially Trusted Code to Use Your Strongly Named Assembly

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 11-2. Disable Code Access Security

      • Problem

      • Solution

      • How It Works

    • 11-3. Disable Execution Permission Checks

      • Problem

      • Solution

      • How It Works

      • The Code

      • Notes

    • 11-4. Ensure the Runtime Grants Specific Permissions to Your Assembly

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-5. Limit the Permissions Granted to Your Assembly

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-6. View the Permissions Required by an Assembly

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 11-7. Determine at Runtime If Your Code Has a Specific Permission

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-8. Restrict Who Can Extend Your Classes and Override Class Members

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-9. Inspect an Assembly’s Evidence

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-10. Determine If the Current User Is a Member of a Specific Windows Group

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 11-11. Restrict Which Users Can Execute Your Code

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-12. Impersonate a Windows User

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 11-13. Create a Cryptographically Random Number

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-14. Calculate the Hash Code of a Password

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 11-15. Calculate the Hash Code of a File

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 11-16. Verify a Hash Code

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-17. Ensure Data Integrity Using a Keyed Hash Code

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 11-18. Work with Security-Sensitive Strings in Memory

      • Problem

      • Solution

      • How It Works

      • The Code

    • 11-19. Encrypt and Decrypt Data Using the Data Protection API

      • Problem

      • Solution

      • How It Works

      • The Code

  • Unmanaged Code Interoperability

    • 12-1. Call a Function in an Unmanaged DLL

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-2. Get the Handle for a Control, Window, or File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-3. Call an Unmanaged Function That Uses a Structure

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-4. Call an Unmanaged Function That Uses a Callback

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-5. Retrieve Unmanaged Error Information

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-6. Use a COM Component in a .NET Client

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-7. Release a COM Component Quickly

      • Problem

      • Solution

      • How It Works

    • 12-8. Use Optional Parameters

      • Problem

      • Solution

      • How It Works

      • The Code

    • 12-9. Use an ActiveX Control in a .NET Client

      • Problem

      • Solution

      • How It Works

    • 12-10. Expose a .NET Component Through COM

      • Problem

      • Solution

      • How It Works

  • Commonly Used Interfaces and Patterns

    • 13-1. Implement a Custom Serializable Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-2. Implement a Cloneable Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-3. Implement a Comparable Type

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 13-4. Implement an Enumerable Collection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-5. Implement an Enumerable Type Using a Custom Iterator

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-6. Implement a Disposable Class

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-7. Implement a Formattable Type

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 13-8. Implement a Custom Exception Class

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-9. Implement a Custom Event Argument

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-10. Implement the Singleton Pattern

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 13-11. Implement the Observer Pattern

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 13-12. Implement a Parallel Producer-Consumer Pattern

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-13. Perform Lazy Object Initialization

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-14. Use Optional Parameters

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-15. Add a Method to a Type Without Modifying It

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-16. Call an Object Member Dynamically

      • Problem

      • Solution

      • How It Works

      • The Code

    • 13-17. Create a Variant Generic Type

      • Problem

      • Solution

      • How It Works

      • The Code

  • Windows Integration

    • 14-1. Access Runtime Environment Information

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-2. Retrieve the Value of an Environment Variable

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-3. Write an Event to the Windows Event Log

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-4. Read and Write to the Windows Registry

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-5. Search the Windows Registry

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 14-6. Create a Windows Service

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 14-7. Create a Windows Service Installer

      • Problem

      • Solution

      • How It Works

      • The Code

      • Usage

    • 14-8. Create a Shortcut on the Desktop or Start Menu

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-9. Create a Windows 7 Jump List

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-10. Use Windows Search

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-11. Check Internet Connectivity

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-12. Display a Task Dialog

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-13. Write Custom Performance Counters

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-14. Read Performance Counters

      • Problem

      • Solution

      • How It Works

      • The Code

    • 14-15. Obtain Elevated Privileges

      • Problem

      • Solution

      • How It Works

      • The Code

  • Parallel Programming

    • 15-1. Perform Simple Parallel Tasks

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-2. Return a Result from a Task

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-3. Wait for Tasks to Complete

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-4. Parallel Process a Collection

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-5. Chain Tasks Together

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-6. Write a Cooperative Algorithm

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-7. Handle Exceptions in Tasks

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-8. Cancel a Task

      • Problem

      • Solution

      • How It Works

      • The Code

    • 15-9. Share Data Between Tasks

      • Problem

      • Solution

      • How It Works

      • The Code

  • Using LINQ

    • 16-1. Perform a Simple LINQ Query

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-2. Filter Items from a Data Source

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-3. Filter a Data Source by Type

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-4. Filter Ranges of Elements

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-5. Select Multiple Member Values

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-6. Filter and Select from Multiple Data Sources

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-7. Use Permutations of Data Sources

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-8. Concatenate Data Sources

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-9. Group Result Elements by Attribute

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-10. Sort Query Results

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-11. Compare Data Sources

      • Problem

      • The Solution

      • How It Works

      • The Code

    • 16-12. Aggregate Data Sources

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-13. Share Values Within a Query

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-14. Create Custom LINQ Extension Methods

      • Problem

      • Solution

      • How It Works

      • The Code

    • 16-15. Convert from IEnumerable<>

      • Problem

      • Solution

      • How It Works

      • The Code

  • Windows Presentation Foundation

    • 17-1. Create and Use a Dependency Property

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-2. Create and Use an Attached Property

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-3. Define Application-Wide Resources

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-4. Debug Data Bindings Using an IValueConverter

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-5. Debug Bindings Using Attached Properties

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-6. Arrange UI Elements in a Horizontal or Vertical Stack

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-7. Dock UI Elements to the Edges of a Form

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-8. Arrange UI Elements in a Grid

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-9. Position UI Elements Using Exact Coordinates

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-10. Get Rich Text Input from a User

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-11. Display a Control Rotated

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-12. Create a User Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-13. Support Application Commands in a User Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-14. Create a Lookless Custom Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-15. Create a Two-Way Binding

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-16. Bind to a Command

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-17. Use Data Templates to Display Bound Data

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-18. Bind to a Collection with the Master-Detail Pattern

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-19. Change a Control’s Appearance on Mouseover

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-20. Change the Appearance of Alternate Items in a List

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-21. Drag Items from a List and Drop Them on a Canvas

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-22. Display the Progress of a Long-Running Operation and Allow the User to Cancel It

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-23. Draw Two-Dimensional Shapes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-24. Create Reusable Shapes

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-25. Draw or Fill a Shape Using a Solid Color

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-26. Fill a Shape with a Linear or Radial Color Gradient

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-27. Fill a Shape with an Image

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-28. Fill a Shape with a Pattern or Texture

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-29. Animate the Property of a Control

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-30. Animate Several Properties in Parallel

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-31. Create a Keyframe-Based Animation

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-32. Animate an Object Along a Path

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-33. Play a Media File

      • Problem

      • Solution

      • How It Works

      • The Code

    • 17-34. Query Keyboard State

      • Problem

      • Solution

      • How It Works

      • The Code

  • Index

    • ¦Numbers & Symbols

    • ¦A

    • ¦B

    • ¦C

    • ¦D

    • ¦E

    • ¦F

    • ¦G

    • ¦H

    • I

    • ¦

    • ¦J

    • K

    • ¦

    • ¦L

    • ¦M

    • ¦N

    • ¦O

    • ¦P

    • ¦Q

    • R

    • ¦

    • ¦S

    • ¦T

    • ¦U

    • ¦V

    • ¦W

    • ¦X

    • ¦Y

    • ¦Z

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

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

Tài liệu liên quan