You are previewing C# 2010 All-in-One For Dummies®.
O'Reilly logo
C# 2010 All-in-One For Dummies®

Book Description

A logical, straightforward approach to learning the C# language

C# is a complicated programming language for building .NET-connected software for Microsoft Windows, the Web, and a wide range of devices. The friendly All-in-One For Dummies format is a perfect way to present it. Each minibook is a self-contained package of necessary information, making it easy to find what you're looking for.

Upgrades in C# 2010 include the ability to build Windows 7 applications and compatibility with Python and Ruby.

  • C# is a somewhat complex programming language for building .NET-connected software for Microsoft Windows, the Web, and other devices

  • Beginning C# programmers will appreciate how the All-in-One format breaks the topic into minibooks, each one addressing a key body of information

  • Minibooks include creating your first C# program, Windows 7 programming, basic C# programming, object-based programming, object-oriented programming, Windows programming with C# and Visual Studio, and debugging

  • Companion Web site includes all sample code

Beginning C# programmers will find C# 2010 All-in-One For Dummies explains a complicated topic in an easy, understandable way.

Table of Contents

  1. Copyright
  2. About the Authors
  3. Acknowledgments
  4. Publisher's Acknowledgments
  5. Introduction
    1. What's New in C# 4.0
    2. About This Book
    3. What You Need in Order to Use This Book
    4. How to Use This Book
    5. How This Book Is Organized
      1. Book I: The Basics of C# Programming
      2. Book II: Object-Oriented C# Programming
      3. Book III: Designing for C#
      4. Book IV: A Tour of Visual Studio
      5. Book V: Windows Development with WPF
      6. Book VI: Web Development with ASP.NET
      7. Book VII: Service-Oriented Development
      8. Book VIII: New Features in C# 4.0
    6. Icons Used in This Book
    7. Conventions Used in This Book
      1. About this book's Web site
    8. Where to Go from Here
  6. I. Basics of C# Programming
    1. 1. Creating Your First C# Console Application
      1. 1.1. Getting a Handle on Computer Languages, C#, and .NET
        1. 1.1.1. What's a program?
        2. 1.1.2. What's C#?
        3. 1.1.3. What's .NET?
        4. 1.1.4. What is Visual Studio 2010? What about Visual C#?
      2. 1.2. Creating Your First Console Application
        1. 1.2.1. Creating the source program
        2. 1.2.2. Taking it out for a test drive
      3. 1.3. Making Your Console App Do Something
      4. 1.4. Reviewing Your Console Application
        1. 1.4.1. The program framework
        2. 1.4.2. Comments
        3. 1.4.3. The meat of the program
      5. 1.5. Introducing the Toolbox Trick
        1. 1.5.1. Saving code in the Toolbox
        2. 1.5.2. Reusing code from the Toolbox
    2. 2. Living with Variability — Declaring Value-Type Variables
      1. 2.1. Declaring a Variable
      2. 2.2. What's an int?
        1. 2.2.1. Rules for declaring variables
        2. 2.2.2. Variations on a theme: Different types of int
      3. 2.3. Representing Fractions
      4. 2.4. Handling Floating-Point Variables
        1. 2.4.1. Declaring a floating-point variable
        2. 2.4.2. Converting some more temperatures
        3. 2.4.3. Examining some limitations of floating-point variables
          1. 2.4.3.1. Counting
          2. 2.4.3.2. Comparing numbers
          3. 2.4.3.3. Calculation speed
          4. 2.4.3.4. Not-so-limited range
      5. 2.5. Using the Decimal Type: Is It an Integer or a Float?
        1. 2.5.1. Declaring a decimal
        2. 2.5.2. Comparing decimals, integers, and floating-point types
      6. 2.6. Examining the bool Type: Is It Logical?
      7. 2.7. Checking Out Character Types
        1. 2.7.1. The char variable type
        2. 2.7.2. Special chars
        3. 2.7.3. The string type
      8. 2.8. What's a Value Type?
      9. 2.9. Comparing string and char
      10. 2.10. Calculating Leap Years: DateTime
      11. 2.11. Declaring Numeric Constants
      12. 2.12. Changing Types: The Cast
      13. 2.13. Letting the C# Compiler Infer Data Types
    3. 3. Pulling Strings
      1. 3.1. The Union Is Indivisible, and So Are Strings
      2. 3.2. Performing Common Operations on a String
      3. 3.3. Comparing Strings
        1. 3.3.1. Equality for all strings: The Compare() method
        2. 3.3.2. Would you like your compares with or without case?
      4. 3.4. What If I Want to Switch Case?
        1. 3.4.1. Distinguishing between all-uppercase and all-lowercase strings
        2. 3.4.2. Converting a string to upper- or lowercase
      5. 3.5. Looping through a String
      6. 3.6. Searching Strings
        1. 3.6.1. Can I find it?
        2. 3.6.2. Is my string empty?
      7. 3.7. Getting Input from the Command Line
        1. 3.7.1. Trimming excess white space
        2. 3.7.2. Parsing numeric input
        3. 3.7.3. Handling a series of numbers
        4. 3.7.4. Joining an array of strings into one string
      8. 3.8. Controlling Output Manually
        1. 3.8.1. Using the Trim() and Pad() methods
        2. 3.8.2. Using the Concatenate() method
        3. 3.8.3. Let's Split() that concatenate program
      9. 3.9. Formatting Your Strings Precisely
      10. 3.10. StringBuilder: Manipulating Strings More Efficiently
    4. 4. Smooth Operators
      1. 4.1. Performing Arithmetic
        1. 4.1.1. Simple operators
        2. 4.1.2. Operating orders
        3. 4.1.3. The assignment operator
        4. 4.1.4. The increment operator
      2. 4.2. Performing Logical Comparisons — Is That Logical?
        1. 4.2.1. Comparing floating-point numbers: Is your float bigger than mine?
        2. 4.2.2. Compounding the confusion with compound logical operations
      3. 4.3. Matching Expression Types at TrackDownAMate.com
        1. 4.3.1. Calculating the type of an operation
          1. 4.3.1.1. Implicit type conversion
          2. 4.3.1.2. Explicit type conversion — the cast
          3. 4.3.1.3. Leave logical alone
        2. 4.3.2. Assigning types
    5. 5. Getting Into the Program Flow
      1. 5.1. Branching Out with if and switch
        1. 5.1.1. Introducing the if statement
        2. 5.1.2. Examining the else statement
        3. 5.1.3. Avoiding even the else
        4. 5.1.4. Nesting if statements
        5. 5.1.5. Running the switchboard
      2. 5.2. Here We Go Loop-the-Loop
        1. 5.2.1. Looping for a while
        2. 5.2.2. Doing the do . . . while loop
        3. 5.2.3. Breaking up is easy to do
        4. 5.2.4. Looping until you get it right
        5. 5.2.5. Focusing on scope rules
      3. 5.3. Looping a Specified Number of Times with for
        1. 5.3.1. An example
        2. 5.3.2. Why do you need another loop?
      4. 5.4. Nesting Loops
      5. 5.5. Don't goto Pieces
    6. 6. Lining Up Your Ducks with Collections
      1. 6.1. The C# Array
        1. 6.1.1. The argument for the array
        2. 6.1.2. The fixed-value array
        3. 6.1.3. The variable-length array
        4. 6.1.4. The Length property
        5. 6.1.5. Initializing an array
      2. 6.2. A Loop Made foreach Array
      3. 6.3. Sorting Arrays of Data
      4. 6.4. New Feature: Using var for Arrays
      5. 6.5. Loosening Up with C# Collections
      6. 6.6. Understanding Collection Syntax
        1. 6.6.1. Figuring out <T>
        2. 6.6.2. Going generic
      7. 6.7. Using Lists
      8. 6.8. Using Dictionaries
      9. 6.9. Array and Collection Initializers
        1. 6.9.1. Initializing arrays
        2. 6.9.2. Initializing collections
      10. 6.10. Using Sets
      11. 6.11. On Not Using Old-Fashioned Collections
    7. 7. Stepping through Collections
      1. 7.1. Iterating through a Directory of Files
      2. 7.2. Iterating foreach Collections: Iterators
        1. 7.2.1. Accessing a collection: The general problem
        2. 7.2.2. Letting C# access data foreach container
      3. 7.3. Accessing Collections the Array Way: Indexers
        1. 7.3.1. Indexer format
        2. 7.3.2. An indexer program example
      4. 7.4. Looping Around the Iterator Block
        1. 7.4.1. Iterating days of the month: A first example
        2. 7.4.2. What a collection is, really
        3. 7.4.3. Iterator syntax gives up so easily
          1. 7.4.3.1. Yield return: Okay, I give up
          2. 7.4.3.2. Yield break: I want out of here!
        4. 7.4.4. Iterator blocks of all shapes and sizes
          1. 7.4.4.1. An iterator named Fred
          2. 7.4.4.2. It's a regular wetland out there!
          3. 7.4.4.3. Iterated property doesn't mean "a house that keeps getting sold"
        5. 7.4.5. Where you can put your iterator
          1. 7.4.5.1. Well, of course, it isn't quite that simple
          2. 7.4.5.2. One more wrinkle
    8. 8. Buying Generic
      1. 8.1. Writing a New Prescription: Generics
        1. 8.1.1. Generics are type-safe
        2. 8.1.2. Generics are efficient
      2. 8.2. Classy Generics: Writing Your Own
        1. 8.2.1. Shipping packages at OOPs
        2. 8.2.2. Queuing at OOPs: PriorityQueue
        3. 8.2.3. Unwrapping the package
          1. 8.2.3.1. Specifying the possible priorities
          2. 8.2.3.2. Implementing the IPrioritizable interface
        4. 8.2.4. Touring Main()
        5. 8.2.5. Writing generic code the easy way
        6. 8.2.6. Saving PriorityQueue for last
          1. 8.2.6.1. The underlying queues
          2. 8.2.6.2. The Enqueue() method
          3. 8.2.6.3. The Dequeue() method
          4. 8.2.6.4. The TopQueue() utility method
          5. 8.2.6.5. The remaining PriorityQueue members
        7. 8.2.7. Using a (nongeneric) Simple Factory class
          1. 8.2.7.1. Using PackageFactory
          2. 8.2.7.2. More about factories
        8. 8.2.8. Tending to unfinished business
          1. 8.2.8.1. Adding constraints
          2. 8.2.8.2. Determining the null value for type T: Default(T)
    9. 9. Some Exceptional Exceptions
      1. 9.1. Using an Exceptional Error-Reporting Mechanism
        1. 9.1.1. About try blocks
        2. 9.1.2. About catch blocks
        3. 9.1.3. About finally blocks
        4. 9.1.4. What happens when an exception is thrown
      2. 9.2. Throwing Exceptions Yourself
      3. 9.3. Knowing What Exceptions Are For
      4. 9.4. Can I Get an Exceptional Example?
        1. 9.4.1. Knowing what makes the example exceptional
        2. 9.4.2. Tracing the stack
      5. 9.5. Assigning Multiple catch Blocks
      6. 9.6. Planning Your Exception-Handling Strategy
        1. 9.6.1. Some questions to guide your planning
        2. 9.6.2. Guidelines for code that handles errors well
        3. 9.6.3. How to analyze a method for possible exceptions
        4. 9.6.4. How to find out which methods throw which exceptions
      7. 9.7. Grabbing Your Last Chance to Catch an Exception
  7. II. Object-Oriented C# Programming
    1. 1. Object-Oriented Programming: What's It All About?
      1. 1.1. Object-Oriented Concept #1: Abstraction
        1. 1.1.1. Preparing procedural nachos
        2. 1.1.2. Preparing object-oriented nachos
      2. 1.2. Object-Oriented Concept #2: Classification
      3. 1.3. Why Classify?
      4. 1.4. Object-Oriented Concept #3: Usable Interfaces
      5. 1.5. Object-Oriented Concept #4: Access Control
      6. 1.6. How C# Supports Object-Oriented Concepts
    2. 2. Showing Some Class
      1. 2.1. Defining a Class and an Object
        1. 2.1.1. Defining a class
        2. 2.1.2. What's the object?
      2. 2.2. Accessing the Members of an Object
      3. 2.3. An Object-Based Program Example
      4. 2.4. Discriminating between Objects
      5. 2.5. Can You Give Me References?
      6. 2.6. Classes That Contain Classes Are the Happiest Classes in the World
      7. 2.7. Generating Static in Class Members
      8. 2.8. Defining const and readonly Data Members
    3. 3. We Have Our Methods
      1. 3.1. Defining and Using a Method
      2. 3.2. A Method Example for Your Files
      3. 3.3. Having Arguments with Methods
        1. 3.3.1. Passing an argument to a method
        2. 3.3.2. Passing multiple arguments to methods
        3. 3.3.3. Matching argument definitions with usage
        4. 3.3.4. Overloading a method doesn't mean giving it too much to do
        5. 3.3.5. Implementing default arguments
      4. 3.4. Returning Values after Christmas
        1. 3.4.1. Returning a value via return postage
        2. 3.4.2. Defining a method with no value
    4. 4. Let Me Say This about this
      1. 4.1. Passing an Object to a Method
      2. 4.2. Defining Methods
        1. 4.2.1. Defining a static method
        2. 4.2.2. Defining an instance method
        3. 4.2.3. Expanding a method's full name
      3. 4.3. Accessing the Current Object
        1. 4.3.1. What is the this keyword?
        2. 4.3.2. When is this explicit?
        3. 4.3.3. What happens when you don't have this?
    5. 5. Holding a Class Responsible
      1. 5.1. Restricting Access to Class Members
        1. 5.1.1. A public example of public BankAccount
        2. 5.1.2. Jumping ahead — other levels of security
      2. 5.2. Why You Should Worry about Access Control
        1. 5.2.1. Accessor methods
        2. 5.2.2. Access control to the rescue — an example
        3. 5.2.3. So what?
      3. 5.3. Defining Class Properties
        1. 5.3.1. Static properties
        2. 5.3.2. Properties with side effects
        3. 5.3.3. New feature: Letting the compiler write properties for you
        4. 5.3.4. Accessors with access levels
      4. 5.4. Getting Your Objects Off to a Good Start — Constructors
      5. 5.5. The C#-Provided Constructor
      6. 5.6. Replacing the Default Constructor
        1. 5.6.1. Constructing something
        2. 5.6.2. Executing the constructor from the debugger
        3. 5.6.3. Initializing an object directly with an initializer
        4. 5.6.4. Seeing that construction stuff with initializers
        5. 5.6.5. New feature: Initializing an object without a constructor
    6. 6. Inheritance: Is That All I Get?
      1. 6.1. Class Inheritance
      2. 6.2. Why You Need Inheritance
      3. 6.3. Inheriting from a BankAccount Class (A More Complex Example)
      4. 6.4. IS_A versus HAS_A — I'm So Confused_A
        1. 6.4.1. The IS_A relationship
        2. 6.4.2. Gaining access to BankAccount by using containment
        3. 6.4.3. The HAS_A relationship
      5. 6.5. When to IS_A and When to HAS_A
      6. 6.6. Other Features That Support Inheritance
        1. 6.6.1. Substitutable classes
        2. 6.6.2. Invalid casts at run time
        3. 6.6.3. Avoiding invalid conversions with the is operator
        4. 6.6.4. Avoiding invalid conversions with the as operator
      7. 6.7. The object Class
      8. 6.8. Inheritance and the Constructor
        1. 6.8.1. Invoking the default base class constructor
        2. 6.8.2. Passing arguments to the base class constructor — mama sang base
        3. 6.8.3. Getting specific with base
      9. 6.9. The Updated BankAccount Class
    7. 7. Poly-what-ism?
      1. 7.1. Overloading an Inherited Method
        1. 7.1.1. It's a simple case of method overloading
        2. 7.1.2. Different class, different method
        3. 7.1.3. Peek-a-boo — hiding a base class method
          1. 7.1.3.1. Making the hiding approach better than adding a simple test
          2. 7.1.3.2. Accidentally hiding a base class method
        4. 7.1.4. Calling back to base
      2. 7.2. Polymorphism
        1. 7.2.1. Using the declared type every time (Is that so wrong?)
        2. 7.2.2. Using is to access a hidden method polymorphically
        3. 7.2.3. Declaring a method virtual and overriding it
        4. 7.2.4. Getting the most benefit from polymorphism — the do-to-each trick
      3. 7.3. The Class Business Card: ToString()
      4. 7.4. C# During Its Abstract Period
        1. 7.4.1. Class factoring
        2. 7.4.2. The abstract class: Left with nothing but a concept
        3. 7.4.3. How do you use an abstract class?
        4. 7.4.4. Creating an abstract object — not!
      5. 7.5. Sealing a Class
    8. 8. Interfacing with the Interface
      1. 8.1. Introducing CAN_BE_USED_AS
      2. 8.2. Knowing What an Interface Is
        1. 8.2.1. How to implement an interface
        2. 8.2.2. How to name your interface
        3. 8.2.3. Why C# includes interfaces
        4. 8.2.4. Mixing inheritance and interface implementation
        5. 8.2.5. And he-e-e-re's the payoff
      3. 8.3. Using an Interface
        1. 8.3.1. As a method return type
        2. 8.3.2. As the base type of an array or collection
        3. 8.3.3. As a more general type of object reference
      4. 8.4. Using the C# Predefined Interface Types
      5. 8.5. Looking at a Program That CAN_BE_USED_AS an Example
        1. 8.5.1. Creating your own interface at home in your spare time
        2. 8.5.2. Implementing the incomparable IComparable<T> interface
        3. 8.5.3. Putting it all together
        4. 8.5.4. Getting back to the Main() event
      6. 8.6. Unifying Class Hierarchies
      7. 8.7. Hiding Behind an Interface
      8. 8.8. Inheriting an Interface
      9. 8.9. Using Interfaces to Manage Change in Object-Oriented Programs
        1. 8.9.1. Making flexible dependencies through interfaces
        2. 8.9.2. Abstract or concrete: When to use an abstract class and when to use an interface
        3. 8.9.3. Doing HAS_A with interfaces
    9. 9. Delegating Those Important Events
      1. 9.1. E.T., Phone Home — The Callback Problem
      2. 9.2. Defining a Delegate
      3. 9.3. Pass Me the Code, Please — Examples
        1. 9.3.1. I delegated the example to Igor
        2. 9.3.2. First, a simple example
      4. 9.4. A More Real-World Example
        1. 9.4.1. Getting an overview of the bigger example
        2. 9.4.2. Putting the app together
        3. 9.4.3. Looking at the code
        4. 9.4.4. Tracking the delegate life cycle
      5. 9.5. Shh! Keep It Quiet — Anonymous Methods
      6. 9.6. Stuff Happens — C# Events
        1. 9.6.1. The Observer design pattern
        2. 9.6.2. What's an event? Publish/Subscribe
        3. 9.6.3. How a publisher advertises its events
        4. 9.6.4. How subscribers subscribe to an event
        5. 9.6.5. How to publish an event
        6. 9.6.6. How to pass extra information to an event handler
        7. 9.6.7. A recommended way to raise your events
        8. 9.6.8. How observers "handle" an event
    10. 10. Can I Use Your Namespace in the Library?
      1. 10.1. Dividing a Single Program into Multiple Source Files
      2. 10.2. Dividing a Single Program into Multiple Assemblies
        1. 10.2.1. Executable or library?
        2. 10.2.2. Assemblies
        3. 10.2.3. Executables
        4. 10.2.4. Class libraries
      3. 10.3. Putting Your Classes into Class Libraries
        1. 10.3.1. Creating the projects for a class library
        2. 10.3.2. Creating a stand-alone class library
        3. 10.3.3. Adding a second project to an existing solution
        4. 10.3.4. Creating classes for the library
        5. 10.3.5. Using a driver program to test a library
        6. 10.3.6. Using a class library from a program
      4. 10.4. Going Beyond Public and Private: More Access Keywords
        1. 10.4.1. Internal: Eyes only at the CIA
        2. 10.4.2. Protected: Sharing with subclasses
        3. 10.4.3. Protected internal: Being a more generous protector
      5. 10.5. Putting Classes into Namespaces
        1. 10.5.1. Declaring a namespace
        2. 10.5.2. Relating namespaces to the access keyword story
          1. 10.5.2.1. Determining whether the class and method you need are visible and accessible to you
          2. 10.5.2.2. Making classes and methods in another namespace visible
        3. 10.5.3. Using fully qualified names
  8. III. Designing for C#
    1. 1. Writing Secure Code
      1. 1.1. Designing Secure Software
        1. 1.1.1. Determining what to protect
        2. 1.1.2. Documenting the components of the program
        3. 1.1.3. Decomposing components into functions
        4. 1.1.4. Identifying potential threats in functions
        5. 1.1.5. Rating the risk
      2. 1.2. Building Secure Windows Applications
        1. 1.2.1. Authentication using Windows login
        2. 1.2.2. Encrypting information
        3. 1.2.3. Deployment security
      3. 1.3. Building Secure Web Forms Applications
        1. 1.3.1. SQL Injection attacks
          1. 1.3.1.1. Understanding SQL Injection
          2. 1.3.1.2. Preventing SQL Injection
        2. 1.3.2. Script exploits
          1. 1.3.2.1. Understanding script exploits
          2. 1.3.2.2. Preventing script exploits
        3. 1.3.3. Best practices for securing Web Forms applications
      4. 1.4. Using System.Security
    2. 2. Accessing Data
      1. 2.1. Getting to Know System.Data
      2. 2.2. How the Data Classes Fit into the Framework
      3. 2.3. Getting to Your Data
      4. 2.4. Using the System.Data Namespace
        1. 2.4.1. Setting up a sample database schema
        2. 2.4.2. Connecting to a data source
        3. 2.4.3. Working with the visual tools
        4. 2.4.4. Writing data code
          1. 2.4.4.1. Output of the visual tools
          2. 2.4.4.2. Basic data code
        5. 2.4.5. Using the Entity Framework
          1. 2.4.5.1. Generating the entity model
          2. 2.4.5.2. Writing code for the entity model
    3. 3. Fishing the FileStream
      1. 3.1. Going Where the Fish Are: The File Stream
        1. 3.1.1. Streams
        2. 3.1.2. Readers and writers
      2. 3.2. StreamWriting for Old Walter
        1. 3.2.1. Using the stream: An example
        2. 3.2.2. Revving up a new outboard StreamWriter
        3. 3.2.3. Finally, we're writing!
        4. 3.2.4. Using some better fishing gear: The using statement
      3. 3.3. Pulling Them Out of the Stream: Using StreamReader
      4. 3.4. More Readers and Writers
      5. 3.5. Exploring More Streams than Lewis and Clark
    4. 4. Accessing the Internet
      1. 4.1. Getting to Know System.Net
      2. 4.2. How Net Classes Fit into the Framework
      3. 4.3. Using the System.Net Namespace
        1. 4.3.1. Checking the network status
        2. 4.3.2. Downloading a file from the Internet
        3. 4.3.3. E-mailing a status report
        4. 4.3.4. Logging network activity
    5. 5. Creating Images
      1. 5.1. Getting to Know System.Drawing
      2. 5.2. Graphics
        1. 5.2.1. Pens
      3. 5.3. Brushes
        1. 5.3.1. Text
      4. 5.4. How the Drawing Classes Fit into the Framework
      5. 5.5. Using the System.Drawing Namespace
        1. 5.5.1. Getting started
        2. 5.5.2. Setting up the project
        3. 5.5.3. Drawing the board
  9. IV. A Tour of Visual Studio
    1. 1. Getting Started with Visual Studio
      1. 1.1. Versioning the Versions
        1. 1.1.1. Express
        2. 1.1.2. Professional
        3. 1.1.3. Team System
        4. 1.1.4. MSDN
        5. 1.1.5. Academic
        6. 1.1.6. An edition breakdown
      2. 1.2. Installing Visual Studio
      3. 1.3. Breaking Down the Projects
        1. 1.3.1. Exploring the New Project dialog box
        2. 1.3.2. Understanding solutions and projects
        3. 1.3.3. A brief survey of the available project categories
    2. 2. Using the Interface
      1. 2.1. Designing in the Designer
        1. 2.1.1. Windows Presentation Foundation (WPF)
        2. 2.1.2. Windows Forms
        3. 2.1.3. Web Forms
        4. 2.1.4. Class Designer
          1. 2.1.4.1. Data View
      2. 2.2. Paneling the Studio
        1. 2.2.1. Solution Explorer
          1. 2.2.1.1. Solutions
          2. 2.2.1.2. Projects
          3. 2.2.1.3. Files
        2. 2.2.2. Properties
        3. 2.2.3. The Toolbox
        4. 2.2.4. Server Explorer
          1. 2.2.4.1. Managed services
          2. 2.2.4.2. Data connections
        5. 2.2.5. Class View
      3. 2.3. Coding in Code View
        1. 2.3.1. Exercising the Code Viewer
          1. 2.3.1.1. Autocompleting with IntelliSense
          2. 2.3.1.2. Outlining
        2. 2.3.2. Exploring the auxiliary windows
      4. 2.4. Using the Tools of the Trade
        1. 2.4.1. The Tools menu
        2. 2.4.2. Building and Debugging
        3. 2.4.3. Refactor menu
    3. 3. Customizing Visual Studio
      1. 3.1. Setting Options
        1. 3.1.1. Environment
          1. 3.1.1.1. Defining the Start Page
          2. 3.1.1.2. Keyboard commands
        2. 3.1.2. Language
        3. 3.1.3. Neat stuff
      2. 3.2. Using Snippets
        1. 3.2.1. Using snippets
        2. 3.2.2. Using surround snippets
        3. 3.2.3. Making snippets
        4. 3.2.4. Deploying snippets
        5. 3.2.5. Sharing snippets
      3. 3.3. Hacking the Project Types
        1. 3.3.1. Hacking Project templates
        2. 3.3.2. Hacking item templates
    4. 4. Transforming Text Templates
      1. 4.1. Getting to Know T4
        1. 4.1.1. Looking back at the DSL Tools
        2. 4.1.2. Looking ahead to what it became
      2. 4.2. Figuring Out When to Use T4
        1. 4.2.1. Replacing repetitive coding
        2. 4.2.2. Building code based on outside data
      3. 4.3. Setting Up the Environment
        1. 4.3.1. Changing the security settings
        2. 4.3.2. Creating a template from a text file
      4. 4.4. Using Some of the T4 Directives
        1. 4.4.1. Setting the output
        2. 4.4.2. Configuring a template
        3. 4.4.3. Including includes
        4. 4.4.4. Importing items and assemblies
  10. V. Windows Development with WPF
    1. 1. Introducing WPF
      1. 1.1. Understanding What WPF Can Do
      2. 1.2. Introducing XAML
      3. 1.3. Diving In! Creating Your First WPF Application
        1. 1.3.1. Declaring an application-scoped resource
        2. 1.3.2. Making the application do something
      4. 1.4. Whatever XAML Can Do, C# Can Do Better!
    2. 2. Understanding the Basics of WPF
      1. 2.1. Using WPF to Lay Out Your Application
      2. 2.2. Arranging Elements with Layout Panels
        1. 2.2.1. The Stack Panel
        2. 2.2.2. The Wrap Panel
        3. 2.2.3. The Dock Panel
        4. 2.2.4. Canvas
        5. 2.2.5. The Uniform Grid
        6. 2.2.6. The Grid
          1. 2.2.6.1. Sizing Rows and Columns
          2. 2.2.6.2. RowSpan and ColumnSpan
          3. 2.2.6.3. Horizontal and vertical alignment within parent container's layout slot
          4. 2.2.6.4. Content alignment within Content Controls
          5. 2.2.6.5. Margin versus padding
          6. 2.2.6.6. Shared size groups
        7. 2.2.7. Putting it all together with a simple data entry form
        8. 2.2.8. Panels of honorable mention
      3. 2.3. Exploring Common XAML Controls
        1. 2.3.1. Display only controls
        2. 2.3.2. Basic input controls
        3. 2.3.3. List-based controls
    3. 3. Data Binding in WPF
      1. 3.1. Getting to Know Dependency Properties
      2. 3.2. Exploring the Binding Modes
      3. 3.3. Investigating the Binding Object
        1. 3.3.1. Defining a binding with XAML
        2. 3.3.2. Defining a binding with C#
      4. 3.4. Editing, Validating, Converting, and Visualizing Your Data
        1. 3.4.1. Validating data
        2. 3.4.2. Converting your data
      5. 3.5. Finding Out More about WPF Data Binding
    4. 4. Practical WPF
      1. 4.1. Commanding Attention
        1. 4.1.1. ICommand
        2. 4.1.2. Routed commands
        3. 4.1.3. Built-in commands
        4. 4.1.4. Focus!
        5. 4.1.5. Custom commands
          1. 4.1.5.1. Custom routed UI commands
          2. 4.1.5.2. Command bindings
          3. 4.1.5.3. Command parameters
          4. 4.1.5.4. Custom commands with ICommand
        6. 4.1.6. Separation of Concerns and testability
          1. 4.1.6.1. First unit test
          2. 4.1.6.2. Test positive and negative conditions
      2. 4.2. Get Your ViewModel On
        1. 4.2.1. Who cares?
        2. 4.2.2. Tradition!
          1. 4.2.2.1. Data Access Layer (DAL)
          2. 4.2.2.2. Model
          3. 4.2.2.3. Business Layer (BL)
          4. 4.2.2.4. View
          5. 4.2.2.5. Introducing the ViewModel
        3. 4.2.3. Show me the code!
          1. 4.2.3.1. Just what are we building?
          2. 4.2.3.2. The model
          3. 4.2.3.3. Model unit tests
          4. 4.2.3.4. Model repositories
          5. 4.2.3.5. The Add Customer command
            1. 4.2.3.5.1. The Add Customer Command unit tests
          6. 4.2.3.6. The ViewModel
            1. 4.2.3.6.1. Testing the ViewModel
          7. 4.2.3.7. The View
          8. 4.2.3.8. Wrap up
  11. VI. Web Development with ASP.NET
    1. 1. Looking at How ASP.NET Works with C#
      1. 1.1. Breaking Down Web Applications
      2. 1.2. Questioning the Client
        1. 1.2.1. Scripting the client
        2. 1.2.2. Getting information back from the client
        3. 1.2.3. Understanding the weaknesses of the browser
      3. 1.3. Dealing with Web Servers
        1. 1.3.1. Getting a PostBack (Hint: It's not a returned package)
          1. 1.3.1.1. Looking back to how things used to be
          2. 1.3.1.2. From the past to the PostBack
        2. 1.3.2. It's a matter of state
    2. 2. Building Web Applications
      1. 2.1. Working in Visual Studio
        1. 2.1.1. Handling the Designer
        2. 2.1.2. Coding in Code View
          1. 2.1.2.1. Adding some functionality using C#
          2. 2.1.2.2. Using Page.Load to add even more functionality
        3. 2.1.3. Recognizing the other file types
      2. 2.2. Developing with Style
        1. 2.2.1. Coding behind
        2. 2.2.2. Scripting the experience
        3. 2.2.3. Building in n-tier
        4. 2.2.4. Modeling the View Controller
    3. 3. Controlling Your Development Experience
      1. 3.1. Showing Stuff to the User
        1. 3.1.1. Labels versus plain old text
        2. 3.1.2. Images
        3. 3.1.3. Panels and multiviews
        4. 3.1.4. Tables
      2. 3.2. Getting Some Input from the User
        1. 3.2.1. Using text input controls
        2. 3.2.2. Using single-item selection controls
        3. 3.2.3. Using multiple-item selection controls
        4. 3.2.4. Using other kinds of input controls
        5. 3.2.5. Submitting input with Submit buttons
      3. 3.3. Data Binding
        1. 3.3.1. Setting up your markup for binding
        2. 3.3.2. Data binding using the code-behind
        3. 3.3.3. Using commonly bound controls
      4. 3.4. Styling Your Controls
        1. 3.4.1. Setting control properties
        2. 3.4.2. Binding styles with CSS
      5. 3.5. Making Sure the Site Is Accessible
        1. 3.5.1. Control features for accessibility
        2. 3.5.2. Design considerations
      6. 3.6. Constructing User Controls
        1. 3.6.1. Making a new phone number user control
        2. 3.6.2. Using your new control
      7. 3.7. Adding Custom Controls
    4. 4. Leveraging the .NET Framework
      1. 4.1. Surfing Web Streams
        1. 4.1.1. Intercepting the request
          1. 4.1.1.1. Digging up the request data
          2. 4.1.1.2. Using information from requests
        2. 4.1.2. Altering content sent to clients
          1. 4.1.2.1. Sending the user somewhere else
          2. 4.1.2.2. Changing the request or response directly
      2. 4.2. Securing with ASP.NET
        1. 4.2.1. Changing trusts
        2. 4.2.2. Fixing problems
      3. 4.3. Navigating with Site Maps
        1. 4.3.1. Adding a site map
        2. 4.3.2. Navigating a site with SiteMap
      4. 4.4. Managing Files
      5. 4.5. Baking Cookies
        1. 4.5.1. Coding for client-side storage
        2. 4.5.2. Wrangling cookies on the server
        3. 4.5.3. How ASP.NET manages cookies for you
      6. 4.6. Tracing with TraceContext
    5. 5. Digging into Web Construction
      1. 5.1. Managing Files
        1. 5.1.1. Reviewing project types
        2. 5.1.2. Reviewing file types
        3. 5.1.3. Organizing files
      2. 5.2. Mastering Master Pages
        1. 5.2.1. Making a master page
        2. 5.2.2. Adding content
      3. 5.3. Testing Web Applications with Visual Studio
      4. 5.4. Deploying Your Masterpiece
        1. 5.4.1. Lots of options
        2. 5.4.2. Copying Web sites with "Copy Web"
        3. 5.4.3. Package/Publish
  12. VII. Service-Oriented Development
    1. 1. Getting Acquainted with Web Services
      1. 1.1. Understanding Web Services
        1. 1.1.1. Loosely coupled
        2. 1.1.2. Contract driven
        3. 1.1.3. Chunky versus chatty
      2. 1.2. Building Service-Oriented Applications
      3. 1.3. Providing XML Web Services
      4. 1.4. Building Three Sample Apps
    2. 2. Building Web Services with ASMX
      1. 2.1. Getting to Know SOAP
        1. 2.1.1. SOAP and standards
        2. 2.1.2. The WS-* standards
        3. 2.1.3. The impact to you
        4. 2.1.4. Big, fat, and slow
      2. 2.2. Making an ASMX Service
        1. 2.2.1. Creating a new service
          1. 2.2.1.1. Analyzing the file setup
          2. 2.2.1.2. Breaking down the sample code
          3. 2.2.1.3. Running the service
        2. 2.2.2. Building the code for SHARP
        3. 2.2.3. Deploying
        4. 2.2.4. Consuming services in your applications
    3. 3. Building Web Services with WCF
      1. 3.1. Getting to Know WCF
      2. 3.2. Creating a WCF Service
        1. 3.2.1. Breaking it down
        2. 3.2.2. Making a registration service
        3. 3.2.3. Configuring
        4. 3.2.4. Deploying
        5. 3.2.5. Consuming
    4. 4. Building Web Services with ReST
      1. 4.1. Getting to Know ReST
      2. 4.2. Understanding the Guiding Principles of ReST
        1. 4.2.1. Diving into the details of ReST
      3. 4.3. Changing a WCF Service to Use ReST
        1. 4.3.1. Getting the WCF service
        2. 4.3.2. Exposing the ReST service
        3. 4.3.3. Returning data in different ways
  13. VIII. New Features in C# 4.0
    1. 1. Programming Dynamically!
      1. 1.1. Shifting C# Toward Dynamic Typing
      2. 1.2. Programming Dynamically
      3. 1.3. Putting Dynamic to Use
        1. 1.3.1. Classic examples
        2. 1.3.2. Making static operations dynamic
        3. 1.3.3. Understanding what's happening under the covers
      4. 1.4. Running with the Dynamic Language Runtime
        1. 1.4.1. Dynamic Ruby
        2. 1.4.2. Dynamic C#
    2. 2. Improving Productivity with Named and Optional Parameters
      1. 2.1. Optional Parameters
        1. 2.1.1. Reference types
        2. 2.1.2. Output parameters
      2. 2.2. Named Parameters
      3. 2.3. Overload Resolution
    3. 3. Helping Out with Interop
      1. 3.1. Using Dynamic Import
      2. 3.2. Working without Primary Interop Assemblies
      3. 3.3. Skipping the Ref Statement
    4. 4. Revising Generics
      1. 4.1. Variance
      2. 4.2. Contravariance
      3. 4.3. Covariance