My Account Log in

1 option

C# 4.0 how-to

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Watson, Ben, Author.
Language:
English
Subjects (All):
C# (Computer program language).
Physical Description:
1 online resource (xiii, 653 p.) : ill.
Edition:
1st edition
Place of Publication:
[Place of publication not identified] Sams 2010
Language Note:
English
System Details:
text file
Summary:
Real Solutions for C# 4.0 Programmers Need fast, robust, efficient code solutions for Microsoft C# 4.0? This book delivers exactly what you’re looking for. You’ll find more than 200 solutions, best-practice techniques, and tested code samples for everything from classes to exceptions, networking to XML, LINQ to Silverlight. Completely up-to-date, this book fully reflects major language enhancements introduced with the new C# 4.0 and .NET 4.0. When time is of the essence, turn here first: Get answers you can trust and code you can use, right now! Beginning with the language essentials and moving on to solving common problems using the .NET Framework, C# 4.0 How-To addresses a wide range of general programming problems and algorithms. Along the way is clear, concise coverage of a broad spectrum of C# techniques that will help developers of all levels become more proficient with C# and the most popular .NET tools. Fast, Reliable, and Easy to Use! Write more elegant, efficient, and reusable code Take advantage of real-world tips and best-practices advice Create more effective classes, interfaces, and types Master powerful data handling techniques using collections, serialization, databases, and XML Implement more effective user interfaces with both WPF and WinForms Construct Web-based and media-rich applications with ASP.NET and Silverlight Make the most of delegates, events, and anonymous methods Leverage advanced C# features ranging from reflection to asynchronous programming Harness the power of regular expressions Interact effectively with Windows and underlying hardware Master the best reusable patterns for designing complex programs
Contents:
Cover
Table of Contents
Introduction
Overview of C# 4.0 How-To
How-To Benefit from This Book
How-To Continue Expanding Your Knowledge
Part I: C# Fundamentals
1 Type Fundamentals
Create a Class
Define Fields, Properties, and Methods
Define Static Members
Add a Constructor
Initialize Properties at Construction
Use const and readonly
Reuse Code in Multiple Constructors
Derive from a Class
Call a Base Class Constructor
Override a Base Class's Method or Property
Create an Interface
Implement Interfaces
Create a Struct
Create an Anonymous Type
Prevent Instantiation with an Abstract Base Class
Interface or Abstract Base Class?
2 Creating Versatile Types
Format a Type with ToString( )
Make Types Equatable
Make Types Hashable with GetHashCode( )
Make Types Sortable
Give Types an Index
Notify Clients when Changes Happen
Overload Appropriate Operators
Convert One Type to Another
Prevent Inheritance
Allow Value Type to Be Null
3 General Coding
Declare Variables
Defer Type Checking to Runtime (Dynamic Types)
Use Dynamic Typing to Simplify COM Interop
Declare Arrays
Create Multidimensional Arrays
Alias a Namespace
Use the Conditional Operator (?:)
Use the Null-Coalescing Operator (??)
Add Methods to Existing Types with Extension Methods
Call Methods with Default Parameters
Call Methods with Named Parameters
Defer Evaluation of a Value Until Referenced
Enforce Code Contracts
4 Exceptions
Throw an Exception
Catch an Exception
Catch Multiple Exceptions
Rethrow an Exception
(Almost) Guarantee Execution with finally
Get Useful Information from an Exception
Create Your Own Exception Class
Catch Unhandled Exceptions
Usage Guidelines
5 Numbers
Decide Between Float, Double, and Decimal.
Use Enormous Integers (BigInteger)
Use Complex Numbers
Format Numbers in a String
Convert a String to a Number
Convert Between Number Bases
Convert a Number to Bytes (and Vice Versa)
Determine if an Integer Is Even
Determine if an Integer Is a Power of 2 (aka, A Single Bit Is Set)
Determine if a Number Is Prime
Count the Number of 1 Bits
Convert Degrees and Radians
Round Numbers
Generate Better Random Numbers
Generate Unique IDs (GUIDs)
6 Enumerations
Declare an Enumeration
Declare Flags as an Enumeration
Determine if a Flag Is Set
Convert an Enumeration to an Integer (and Vice Versa)
Determine if an Enumeration Is Valid
List Enumeration Values
Convert a String to an Enumeration
Attach Metadata to Enums with Extension Methods
Enumeration Tips
7 Strings
Convert a String to Bytes (and Vice Versa)
Create a Custom Encoding Scheme
Compare Strings Correctly
Change Case Correctly
Detect Empty Strings
Concatenate Strings: Should You Use StringBuilder?
Concatenate Collection Items into a String
Append a Newline Character
Split a String
Convert Binary Data to a String (Base-64 Encoding)
Reverse Words
Sort Number Strings Naturally
8 Regular Expressions
Search Text
Extract Groups of Text
Replace Text
Match and Validate
Help Regular Expressions Perform Better
9 Generics
Create a Generic List
Create a Generic Method
Create a Generic Interface
Create a Generic Class
Create a Generic Delegate
Use Multiple Generic Types
Constrain the Generic Type
Convert IEnumerable&lt
string&gt
to IEnumerable&lt
object&gt
(Covariance)
Convert IComparer&lt
Child&gt
to IComparer&lt
Parent&gt
(Contravariance)
Create Tuples (Pairs and More)
Part II: Handling Data
10 Collections.
Pick the Correct Collection Class
Initialize a Collection
Iterate over a Collection Independently of Its Implementation
Create a Custom Collection
Create Custom Iterators for a Collection
Reverse an Array
Reverse a Linked List
Get the Unique Elements from a Collection
Count the Number of Times an Item Appears
Implement a Priority Queue
Create a Trie (Prefix Tree)
11 Files and Serialization
Create, Read, and Write Files
Delete a File
Combine Streams (Compress a File)
Get a File Size
Get File Security Description
Check for File and Directory Existence
Enumerate Drives
Enumerate Directories and Files
Browse for Directories
Search for a File or Directory
Manipulate File Paths
Create Unique or Temporary Filenames
Watch for File System Changes
Get the Paths to My Documents, My Pictures, Etc.
Serialize Objects
Serialize to an In-Memory Stream
Store Data when Your App Has Restricted Permissions
12 Networking and the Web
Resolve a Hostname to an IP Address
Get This Machine's Hostname and IP Address
Ping a Machine
Get Network Card Information
Create a TCP/IP Client and Server
Send an Email via SMTP
Download Web Content via HTTP
Upload a File with FTP
Strip HTML of Tags
Embed a Web Browser in Your Application
Consume an RSS Feed
Produce an RSS Feed Dynamically in IIS
Communicate Between Processes on the Same Machine (WCF)
Communicate Between Two Machines on the Same Network (WCF)
Communicate over the Internet (WCF)
Discover Services During Runtime (WCF)
13 Databases
Create a New Database from Visual Studio
Connect and Retrieve Data
Insert Data into a Database Table
Delete Data from a Table
Run a Stored Procedure
Use Transactions
Bind Data to a Control Using a DataSet.
Detect if Database Connection Is Available
Automatically Map Data to Objects with the Entity Framework
14 XML
Serialize an Object to and from XML
Write XML from Scratch
Read an XML File
Validate an XML Document
Query XML Using XPath
Transform Database Data to XML
Transform XML to HTML
Part III: User Interaction
15 Delegates, Events, and Anonymous Methods
Decide Which Method to Call at Runtime
Subscribe to an Event
Publish an Event
Ensure UI Updates Occur on UI Thread
Assign an Anonymous Method to a Delegate
Use Anonymous Methods as Quick-and-Easy Event Handlers
Take Advantage of Contravariance
16 Windows Forms
Create Modal and Modeless Forms
Add a Menu Bar
Disable Menu Items Dynamically
Add a Status Bar
Add a Toolbar
Create a Split Window Interface
Inherit a Form
Create a User Control
Use a Timer
Use Application and User Configuration Values
Use ListView Efficiently in Virtual Mode
Take Advantage of Horizontal Wheel Tilt
Cut and Paste
Automatically Ensure You Reset the Wait Cursor
17 Graphics with Windows Forms and GDI+
Understand Colors
Use the System Color Picker
Convert Colors Between RGB to HSV
Draw Shapes
Create Pens
Create Custom Brushes
Use Transformations
Draw Text
Draw Text Diagonally
Draw Images
Draw Transparent Images
Draw to an Off-Screen Buffer
Access a Bitmap's Pixels Directly for Performance
Draw with Anti-Aliasing
Draw Flicker-Free
Resize an Image
Create a Thumbnail of an Image
Take a Multiscreen Capture
Get the Distance from the Mouse Cursor to a Point
Determine if a Point Is Inside a Rectangle
Determine if a Point Is Inside a Circle
Determine if a Point Is Inside an Ellipse
Determine if Two Rectangles Intersect
Print and Print Preview
18 WPF
Show a Window.
Choose a Layout Method
Use Standard Commands
Use Custom Commands
Enable and Disable Commands
Expand and Collapse a Group of Controls
Respond to Events
Separate Look from Functionality
Use Triggers to Change Styles at Runtime
Bind Control Properties to Another Object
Format Values During Data Binding
Convert Values to a Different Type During Data Binding
Bind to a Collection
Specify How Bound Data Is Displayed
Define the Look of Controls with Templates
Animate Element Properties
Render 3D Geometry
Put Video on a 3D Surface
Put Interactive Controls onto a 3D Surface
Use WPF in a WinForms App
Use WinForms in a WPF Application
19 ASP.NET
View Debug and Trace Information
Determine Web Browser Capabilities
Redirect to Another Page
Use Forms Authentication for User Login
Use Master Pages for a Consistent Look
Add a Menu
Bind Data to a GridView
Create a Flexible UI with Web Parts
Create a Simple AJAX Page
Do Data Validation
Maintain Application State
Maintain UI State
Maintain User Data in a Session
Store Session State
Use Cookies to Restore Session State
Use ASP.NET Model-View-Controller (MVC)
20 Silverlight
Create a Silverlight Project
Play a Video
Build a Download and Playback Progress Bar
Response to Timer Events on the UI Thread
Put Content into a 3D Perspective
Make Your Application Run out of the Browser
Capture a Webcam
Print a Document
Part IV: Advanced C#
21 LINQ
Query an Object Collection
Order the Results
Filter a Collection
Get a Collection of a Portion of Objects (Projection)
Perform a Join
Query XML
Create XML
Query the Entity Framework
Query a Web Service (LINQ to Bing).
Speed Up Queries with PLINQ (Parallel LINQ).
Notes:
Bibliographic Level Mode of Issuance: Monograph
Description based on publisher supplied metadata and other sources.
ISBN:
9786612599026
9780672331961
0672331969
9781282599024
128259902X
9780672331954
0672331950
OCLC:
1027199657

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account