Book description
When you are facing a Visual C# 2010 problem, this book likely contains a recipe that provides you with the solution-or at least points you in the right direction. Even if you are simply looking to broaden your knowledge of the .NET Framework class library, then Visual C# 2010 Recipes is the perfect resource to assist you.
Table of contents
- Copyright
- About the Authors
- About the Technical Reviewer
- Acknowledgments
- Introduction
-
1. Application Development
- 1.1. Create a Console Application from the Command Line
- 1.2. Create a Windows-Based Application from the Command Line
- 1.3. Create and Use a Code Module
- 1.4. Create and Use a Code Library from the Command Line
- 1.5. Access Command-Line Arguments
- 1.6. Include Code Selectively at Build Time
- 1.7. Access a Program Element That Has the Same Name As a Keyword
- 1.8. Create and Manage Strongly Named Key Pairs
- 1.9. Give an Assembly a Strong Name
- 1.10. Verify That a Strongly 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
- 1.14. Manage the Global Assembly Cache
- 1.15. Prevent People from Decompiling Your Code
- 1.16. Manipulate the Appearance of the Console
- 1.17. Create a Static Class
- 1.18. Create an Anonymous Type
- 1.19. Create an ExpandoObject Dynamic Type
- 1.20. Define an Automatically Implemented Property
- 1.21. Overload an Operator
- 1.22. Define a Conversion Operator
- 1.23. Handle an Event with an Anonymous Function
- 1.24. Implement a Custom Indexer
-
2. Data Manipulation
- 2.1. Manipulate the Contents of a String Efficiently
- 2.2. Encode a String Using Alternate Character Encoding
- 2.3. Convert Basic Value Types to Byte Arrays
- 2.4. Base64 Encode Binary Data
- 2.5. Validate Input Using Regular Expressions
- 2.6. Use Compiled Regular Expressions
- 2.7. Create Dates and Times from Strings
- 2.8. Add, Subtract, and Compare Dates and Times
- 2.9. Sort an Array or a Collection
- 2.10. Copy a Collection to an Array
- 2.11. Use a Strongly Typed Collection
- 2.12. Create a Generic Type
- 2.13. Store a Serializable Object to a File
- 2.14. Serialize an Object Using JSON
- 2.15. Read User Input from the Console
- 2.16. Using Large Integer Values
- 2.17. Select Collection or Array Elements
- 2.18. Remove Duplicate Items from an Array or Collection
-
3. Application Domains, Reflection, and Metadata
- 3.1. Create an Application Domain
- 3.2. Create Types That Can Be Passed Across Application Domain Boundaries
- 3.3. Avoid Loading Unnecessary Assemblies into Application Domains
- 3.4. Create a Type That Cannot Cross Application Domain Boundaries
- 3.5. Load an Assembly into the Current Application Domain
- 3.6. Execute an Assembly in a Different Application Domain
- 3.7. Instantiate a Type in a Different Application Domain
- 3.8. Pass Data Between Application Domains
- 3.9. Unload Assemblies and Application Domains
- 3.10. Retrieve Type Information
- 3.11. Test an Object's Type
- 3.12. Instantiate an Object Using Reflection
- 3.13. Create a Custom Attribute
- 3.14. Inspect the Attributes of a Program Element Using Reflection
- 3.15. Programmatically Discover the Members of a Type
- 3.16. Invoke a Type Member Using Reflection
- 3.17. Dynamically Invoke a Type Member
- 3.18. Create a Custom Dynamic Type
-
4. Threads, Processes, and Synchronization
- 4.1. Execute a Method Using the Thread Pool
- 4.2. Execute a Method Asynchronously
- 4.3. Execute a Method Periodically
- 4.4. Execute a Method at a Specific Time
- 4.5. Execute a Method by Signaling a WaitHandle Object
- 4.6. Execute a Method Using a New Thread
- 4.7. Synchronize the Execution of Multiple Threads Using a Monitor
- 4.8. Synchronize the Execution of Multiple Threads Using an Event
- 4.9. Synchronize the Execution of Multiple Threads Using a Mutex
- 4.10. Synchronize the Execution of Multiple Threads Using a Semaphore
- 4.11. Synchronize Access to a Shared Data Value
- 4.12. Know When a Thread Finishes
- 4.13. Terminate the Execution of a Thread
- 4.14. Create a Thread-Safe Collection Instance
- 4.15. Start a New Process
- 4.16. Terminate a Process
- 4.17. Ensure That Only One Instance of an Application Can Execute Concurrently
-
5. Files, Directories, and I/O
- 5.1. Retrieve Information About a File, Directory, or Drive
- 5.2. Set File and Directory Attributes
- 5.3. Copy, Move, or Delete a File or Directory
- 5.4. Calculate the Size of a Directory
- 5.5. Retrieve Version Information for a File
- 5.6. Show a Just-in-Time Directory Tree in the TreeView Control
- 5.7. Read and Write a Text File
- 5.8. Read and Write a Binary File
- 5.9. Read a File Asynchronously
- 5.10. Find Files That Match a Wildcard Expression
- 5.11. Test Two Files for Equality
- 5.12. Manipulate Strings Representing File Names
- 5.13. Determine If a Path Is a Directory or a File
- 5.14. Work with Relative Paths
- 5.15. Create a Temporary File
- 5.16. Get the Total Free Space on a Drive
- 5.17. Show the Common File Dialog Boxes
- 5.18. Use an Isolated Store
- 5.19. Monitor the File System for Changes
- 5.20. Access a COM Port
- 5.21. Get a Random File Name
- 5.22. Manipulate the Access Control List of a File or Directory
- 5.23. Compress Data
- 5.24. Log Data to a File
- 5.25. Process a Log File
- 5.26. Communicate Between Processes
-
6. XML Processing
- 6.1. Show the Structure of an XML Document in a TreeView
- 6.2. Insert Nodes in an XML Document
- 6.3. Quickly Append Nodes in an XML Document
- 6.4. Find Specific Elements by Name
- 6.5. Get XML Nodes in a Specific XML Namespace
- 6.6. Find Elements with an XPath Search
- 6.7. Read and Write XML Without Loading an Entire Document into Memory
- 6.8. Validate an XML Document Against a Schema
- 6.9. Use XML Serialization with Custom Objects
- 6.10. Create a Schema for a .NET Class
- 6.11. Generate a Class from a Schema
- 6.12. Perform an XSL Transform
- 6.13. Load XML with LINQ
- 6.14. Create a New XML Tree with LINQ
- 6.15. Query XML with LINQ
- 6.16. Modify an XML Tree with LINQ
-
7. Windows Forms
- 7.1. Add a Control Programmatically
- 7.2. Store Data with a Control
- 7.3. Process All the Controls on a Form
- 7.4. Track the Visible Forms in an Application
- 7.5. Find All MDI Child Forms
- 7.6. Save Configuration Settings for a Form
- 7.7. Force a List Box to Scroll to the Most Recently Added Item
- 7.8. Restrict a Text Box to Accept Only Specific Input
- 7.9. Use an Autocomplete Combo Box or Text Box
- 7.10. Sort a List View by Any Column
- 7.11. Lay Out Controls Automatically
- 7.12. Use Part of a Main Menu for a Context Menu
- 7.13. Make a Multilingual Form
- 7.14. Create a Form That Cannot Be Moved
- 7.15. Make a Borderless Form Movable
- 7.16. Create an Animated System Tray Icon
- 7.17. Validate an Input Control
- 7.18. Use a Drag-and-Drop Operation
- 7.19. Update the User Interface in a Multithreaded Application
- 7.20. Display a Web Page in a Windows-Based Application
- 7.21. Display WPF Windows in a Windows Forms Application
- 7.22. Display WPF Controls in Windows Forms
-
8. Graphics, Multimedia, and Printing
- 8.1. Find All Installed Fonts
- 8.2. Perform Hit Testing with Shapes
- 8.3. Create an Irregularly Shaped Control
- 8.4. Create a Movable Sprite
- 8.5. Create a Scrollable Image
- 8.6. Perform a Screen Capture
- 8.7. Use Double Buffering to Increase Redraw Speed
- 8.8. Show a Thumbnail for an Image
- 8.9. Play a Simple Beep or System Sound
- 8.10. Play a WAV File
- 8.11. Play a Sound File
- 8.12. Play a Video
- 8.13. Retrieve Information About Installed Printers
- 8.14. Print a Simple Document
- 8.15. Print a Multipage Document
- 8.16. Print Wrapped Text
- 8.17. Show a Dynamic Print Preview
- 8.18. Manage Print Jobs
- 8.19. Perform Text-to-Speech
- 8.20. Recognize Characters in an Image (OCR)
-
9. Database Access
- 9.1. Connect to a Database
- 9.2. Use Connection Pooling
- 9.3. Create a Database Connection String Programmatically
- 9.4. Store a Database Connection String Securely
- 9.5. Execute a SQL Command or Stored Procedure
- 9.6. Use Parameters in a SQL Command or Stored Procedure
- 9.7. Process the Results of a SQL Query Using a Data Reader
- 9.8. Obtain an XML Document from a SQL Server Query
- 9.9. Perform Asynchronous Database Operations Against SQL Server
- 9.10. Write Database-Independent Code
- 9.11. Discover All Instances of SQL Server on Your Network
- 9.12. Create an In-Memory Cache
- 9.13. Create a DataSet Programmatically
- 9.14. Perform a LINQ Query
- 9.15. Perform a LINQ Query with Entity Types
- 9.16. Compare LINQ DataSet Results
-
10. Networking
- 10.1. Obtain Information About the Local Network Interface
- 10.2. Detect Changes in Network Connectivity
- 10.3. Download Data over HTTP or FTP
- 10.4. Download a File and Process It Using a Stream
- 10.5. Respond to HTTP Requests from Within Your Application
- 10.6. Get an HTML Page from a Site That Requires Authentication
- 10.7. Send E-mail Using SMTP
- 10.8. Resolve a Host Name to an IP Address
- 10.9. Ping an IP Address
- 10.10. Communicate Using TCP
- 10.11. Create a Multithreaded TCP Server That Supports Asynchronous Communications
- 10.12. Communicate Using UDP
- 10.13. Create a SOAP-Based Web Service
- 10.14. Call a WCF Service Using a Dynamically Generated Service Proxy
- 10.15. Process the Content of an Atom or RSS Feed
- 10.16. Manipulate URIs
-
11. Security and Cryptography
- 11.1. Allow Partially Trusted Code to Use Your Strongly Named Assembly
- 11.2. Disable Code Access Security
- 11.3. Disable Execution Permission Checks
- 11.4. Ensure the Runtime Grants Specific Permissions to Your Assembly
- 11.5. Limit the Permissions Granted to Your Assembly
- 11.6. View the Permissions Required by an Assembly
- 11.7. Determine at Runtime If Your Code Has a Specific Permission
- 11.8. Restrict Who Can Extend Your Classes and Override Class Members
- 11.9. Inspect an Assembly's Evidence
- 11.10. Determine If the Current User Is a Member of a Specific Windows Group
- 11.11. Restrict Which Users Can Execute Your Code
- 11.12. Impersonate a Windows User
- 11.13. Create a Cryptographically Random Number
- 11.14. Calculate the Hash Code of a Password
- 11.15. Calculate the Hash Code of a File
- 11.16. Verify a Hash Code
- 11.17. Ensure Data Integrity Using a Keyed Hash Code
- 11.18. Work with Security-Sensitive Strings in Memory
- 11.19. Encrypt and Decrypt Data Using the Data Protection API
-
12. Unmanaged Code Interoperability
- 12.1. Call a Function in an Unmanaged DLL
- 12.2. Get the Handle for a Control, Window, or File
- 12.3. Call an Unmanaged Function That Uses a Structure
- 12.4. Call an Unmanaged Function That Uses a Callback
- 12.5. Retrieve Unmanaged Error Information
- 12.6. Use a COM Component in a .NET Client
- 12.7. Release a COM Component Quickly
- 12.8. Use Optional Parameters
- 12.9. Use an ActiveX Control in a .NET Client
- 12.10. Expose a .NET Component Through COM
-
13. Commonly Used Interfaces and Patterns
- 13.1. Implement a Custom Serializable Type
- 13.2. Implement a Cloneable Type
- 13.3. Implement a Comparable Type
- 13.4. Implement an Enumerable Collection
- 13.5. Implement an Enumerable Type Using a Custom Iterator
- 13.6. Implement a Disposable Class
- 13.7. Implement a Formattable Type
- 13.8. Implement a Custom Exception Class
- 13.9. Implement a Custom Event Argument
- 13.10. Implement the Singleton Pattern
- 13.11. Implement the Observer Pattern
- 13.12. Implement a Parallel Producer-Consumer Pattern
- 13.13. Perform Lazy Object Initialization
- 13.14. Use Optional Parameters
- 13.15. Add a Method to a Type Without Modifying It
- 13.16. Call an Object Member Dynamically
- 13.17. Create a Variant Generic Type
-
14. Windows Integration
- 14.1. Access Runtime Environment Information
- 14.2. Retrieve the Value of an Environment Variable
- 14.3. Write an Event to the Windows Event Log
- 14.4. Read and Write to the Windows Registry
- 14.5. Search the Windows Registry
- 14.6. Create a Windows Service
- 14.7. Create a Windows Service Installer
- 14.8. Create a Shortcut on the Desktop or Start Menu
- 14.9. Create a Windows 7 Jump List
- 14.10. Use Windows Search
- 14.11. Check Internet Connectivity
- 14.12. Display a Task Dialog
- 14.13. Write Custom Performance Counters
- 14.14. Read Performance Counters
- 14.15. Obtain Elevated Privileges
- 15. Parallel Programming
-
16. Using LINQ
- 16.1. Perform a Simple LINQ Query
- 16.2. Filter Items from a Data Source
- 16.3. Filter a Data Source by Type
- 16.4. Filter Ranges of Elements
- 16.5. Select Multiple Member Values
- 16.6. Filter and Select from Multiple Data Sources
- 16.7. Use Permutations of Data Sources
- 16.8. Concatenate Data Sources
- 16.9. Group Result Elements by Attribute
- 16.10. Sort Query Results
- 16.11. Compare Data Sources
- 16.12. Aggregate Data Sources
- 16.13. Share Values Within a Query
- 16.14. Create Custom LINQ Extension Methods
- 16.15. Convert from IEnumerable<>
-
17. Windows Presentation Foundation
- 17.1. Create and Use a Dependency Property
- 17.2. Create and Use an Attached Property
- 17.3. Define Application-Wide Resources
- 17.4. Debug Data Bindings Using an IValueConverter
- 17.5. Debug Bindings Using Attached Properties
- 17.6. Arrange UI Elements in a Horizontal or Vertical Stack
- 17.7. Dock UI Elements to the Edges of a Form
- 17.8. Arrange UI Elements in a Grid
- 17.9. Position UI Elements Using Exact Coordinates
- 17.10. Get Rich Text Input from a User
- 17.11. Display a Control Rotated
- 17.12. Create a User Control
- 17.13. Support Application Commands in a User Control
- 17.14. Create a Lookless Custom Control
- 17.15. Create a Two-Way Binding
- 17.16. Bind to a Command
- 17.17. Use Data Templates to Display Bound Data
- 17.18. Bind to a Collection with the Master-Detail Pattern
- 17.19. Change a Control's Appearance on Mouseover
- 17.20. Change the Appearance of Alternate Itemsin a List
- 17.21. Drag Items from a List and Drop Them onaCanvas
- 17.22. Display the Progress of a Long-Running Operation and Allow the User to Cancel It
- 17.23. Draw Two-Dimensional Shapes
- 17.24. Create Reusable Shapes
- 17.25. Draw or Fill a Shape Using a Solid Color
- 17.26. Fill a Shape with a Linear or Radial Color Gradient
- 17.27. Fill a Shape with an Image
- 17.28. Fill a Shape with a Pattern or Texture
- 17.29. Animate the Property of a Control
- 17.30. Animate Several Properties in Parallel
- 17.31. Create a Keyframe-Based Animation
- 17.32. Animate an Object Along a Path
- 17.33. Play a Media File
- 17.34. Query Keyboard State
Product information
- Title: Visual C# 2010 Recipes: A Problem-Solution Approach
- Author(s):
- Release date: March 2010
- Publisher(s): Apress
- ISBN: 9781430225256
You might also like
book
Introducing Visual C# 2010
If you're new to C# programming, this book is the ideal way to get started. Respected …
video
C# 2012 Fundamentals LiveLessons Parts I, II, III, and IV
C# 2012 Fundamentals LiveLessonspresents Paul Deitel's signature "Live Code" treatment of Microsoft's C# 2012 programming language …
book
Professional C# 5.0 and .NET 4.5.1
Comprehensive, advanced coverage of C# 5.0 and .NET 4.5.1 Whether you're a C# guru or transitioning …
book
C# 6.0 in a Nutshell, 6th Edition
When you have questions about C# 6.0 or the .NET CLR and its core Framework assemblies, …