Home > Store

C# 4.0 Unleashed

Register your product to gain access to bonus material or receive a coupon.

C# 4.0 Unleashed

eBook (Watermarked)

  • Your Price: $35.19
  • List Price: $43.99
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.


  • Copyright 2011
  • Dimensions: 7 X 9-1/8
  • Pages: 1080
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-268173-0
  • ISBN-13: 978-0-13-268173-5

C# 4.0 Unleashed is a practical reference focusing on the C# language and the .NET platform as a whole. While covering the language in lots of detail, it also provides enough coverage of various popular .NET technologies and techniques (such as debugging) for the reader to be successful on the .NET platform. The in-depth coverage of the language features is crucial to the success of a developer. Knowing exactly where and why to use certain language features can boost efficiency significantly. This book differs from other works by going into enough depth on how things work, while not being a clone of the formal language specification. Concise anecdotes with concrete samples illustrate how certain language features behave, and also point out possible caveats in using them. On the side of platform coverage, the author provides a gentle introduction to the wide landscape of the .NET platform, following a logical structure that reflects the high-level architecture of an application: presentation, logic, data, connectivity, etc. In the .NET part of the book there's coverage of relevant new technologies such as cloud computing, modeling, and parallel programming - things that will gain much more attention moving forward.

  • Provides valuable insight into the C# language and the .NET Framework - not just "what" but also the "how" and "why" of the language and framework features
  • Covers using C# with new major technologies, such as cloud computing, SharePoint, and ASP.NET MVC
  • Author is Microsoft insider
  • Will be day and date with the release of C# 4.0
  • Sample Content

    Table of Contents

    Introduction 1

    Part I Introduction

    Chapter 1 Introducing the .NET Platform 5

    A Historical Perspective5

        Win32 Programming in C 6

        Raising the Abstraction Level with MFC and C++ 6

        Component-Driven Development with COM 7

        Windows Development for the Masses in Visual Basic 7

        Reaching Out to the Web with Windows DNA8

        Reaching Out to Java with J++8

        Time for Lightning8

    A 10,000-Feet View of the .NET Platform 9

        The .NET Platform 9

    The Common Language Infrastructure

    The Multilanguage Aspect of .NET

    Introducing .NET Assemblies

    The Common Type System Explained

        What’s Type Safety?

        Primitive Types

        Classes, Structures, and Enumerations




        A Note on Generics

        The Role of the Common Language Specification

    Executing Managed Code

        The Assembly Manifest

        IL Code


        Mixing Languages

    Diving into the Common Language Runtime

        Bootstrapping the Runtime

        Assembly Loading

        Application Domains

        JIT Compilation

        Native Image Generation

        Automatic Memory Management

        Exception Handling

        Code Access Security

        Interoperability Facilities

        The Base Class Library


    Chapter 2 Introducing the C# Programming Language

    The Evolution of C#

        C# 1.0: Managed Code Development, Take One

        C# 2.0: Enriching the Core Language Features

        C# 3.0: Bridging the Gap Between Objects and Data

        C# 4.0: Reaching Out to Dynamic Languages

    A Sneak Peek at the Future


        Language-Shaping Forces

        Compiler as a Service

        Taming the Concurrency Beast


    Chapter 3 Getting Started with .NET Development Using C#

    Installing the .NET Framework

        The .NET Framework Version Landscape

        .NET Framework 4

        Running the Installer

        What Got Installed?

    Your First Application: Take One

        Writing the Code

        Compiling It

        Running It

        Inspecting Our Assembly with .NET Reflector

    Visual Studio 2010



        Installing Visual Studio 2010

        A Quick Tour Through Visual Studio 2010

    Your First Application: Take Two

        New Project Dialog

        Solution Explorer

        Project Properties

        Code Editor

        Build Support

        Debugging Support

        Object Browser

        Code Insight

        Integrated Help


        Server Explorer

        Database Mappers

        Unit Testing

        Team Development


    Part II C#—The Language

    Chapter 4 Language Essentials

    The Entry Point

        A Trivial Console Application

        Method Signatures

        Allowed Entry-Point Signatures

        Running the Sample

        Under the Hood


        Contextual Keywords

        Syntax Highlighting in Visual Studio

    A Primer on Types

        Code and Data

        Types, Objects, and Instances


        Classes and Other Types

    Built-In Types

        Integral Types

        Floating-Point Types

        The Decimal Type

        The Boolean Type

        The String Type


        Dynamic Typing

        A Word on CLS Compliance

        A Matter of Style: Aliases or Not?

    Local Variables





        Implicitly Typed Local Variable Declarations

    Intermezzo on Comments

        Single-Line Comments

        A Primer to Preprocessing Directives

        Delimited Comments

        Documentation Comments


        Internal Representation

        Single-Dimensional Arrays

        Array Initializers

        Jagged Arrays

        Multidimensional Arrays

    The Null Reference

        What’s Null Really?

        A Common Source of Bugs

    Nullable Value Types

        Internal Representation

        Use in C#

        A Type Background


    Chapter 5 Expressions and Operators

    What Are Expressions?

        Arity of Operators

        Precedence and Associativity

        Evaluation of Subexpressions

    The Evaluation Stack

    Arithmetic Operators

        Integer Arithmetic

        Floating-Point Arithmetic

        Decimal Arithmetic

        Character Arithmetic

        Unary Plus and Minus

        Overflow Checking

        Arithmetic with Nullables

    String Concatenation

    Shift Operators

    Relational Operators

        Equality for Different Types

        Lifted Operators

    Logical Operators

        Integral Bitwise Logical Operators

        Use for Enumerations

        Boolean Logical Operators

        Nullable Boolean Logic

    Conditional Operators

        Under the Hood

    An Operator’s Result Type


    Null-Coalescing Operator


        Decaration Versus (Simple) Assignment

        Compound Assignment

        A Gentle Introduction to Definite Assignment

        Postfix and Prefix Increment and Decrement Operators


    Chapter 6 A Primer on Types and Objects

    Implicit Versus Explicit Conversions

        Cast Expressions

        The is Operator

        The as Operator

        Intermezzo: The Mythical Type Switch

    The typeof Operator: A Sneak Peek at Reflection

    Default Value Expression

    Creating Objects with the new Operator

        Behind the Scenes of Constructors

        Object Initializers

        Collection Initializers

    Member Access

        A First Look at Dynamic Typing

    Invocation Expressions

        Method Invocation

        Delegate Invocation

    Element Access


    Chapter 7 Simple Control Flow

    What Are Statements, Anyway?

    Expression Statements

        Method Calls


        Pre- and Post-Increment/Decrement

    The Empty Statement



    Selection Statements

        The if Statement

        The switch Statement

    Iteration Statements

        The while Statement

        The do...while Statement

        The for Statement

        The foreach Statement

    A Peek at Iterators

    Loops in the Age of Concurrency

    The goto Statement

    The return Statement


    Chapter 8 Basics of Exceptions and Resource Management

    Exception Handling

        Exceptions Are Objects

        Causes of Exceptions

        Throwing Exceptions

        Handling Exceptions

        The finally Clause

    Deterministic Resource Cleanup

        Garbage Collection in a Nutshell

        Object Disposal

        The using Statement

        Implementing IDisposable

         (In)appropriate Use of IDisposable

    Locking on Objects

        Under the Hood

        The lock Statement

        Intermezzo: Code Generation for Lock

        Be Careful with Locks


    Chapter 9 Introducing Types

    Types Revisited

    Classes Versus Structs

        References Versus Values

        Heap Versus Stack


        The Dangers of Mutable Value Types

    Type Members


        Static Versus Instance

        Partial Types


    Chapter 10 Methods

    Defining Methods

    Return Type


        Value Parameters

        Reference Parameters

        Output Parameters

        Parameter Arrays

        Optional and Named Parameters


        Defining Method Overloads

        Method Groups

        Overload Resolution

    Extension Methods

        Defining Extension Methods

        Overload Resolution

        Using Extension Methods

        How the Compiler Marks and Finds Extension Methods

    Partial Methods

    Extern Methods


    Code Analysis


    Chapter 11 Fields, Properties, and Indexers


        Declaring Fields

        Accessing Fields

        Initializing Fields

        Read-Only Fields


        Volatile Fields

    An Intermezzo About Enums

        Why Enums Matter

        Underlying Types

        Assigning Values to Members

        The System.Enum Type


        Revisiting the switch Statement

        Behind the Scenes


        Declaring and Using Properties

        Auto-Implemented Properties

        How Properties Work


        Defining Indexers

        How Indexers Are Implemented


    Chapter 12 Constructors and Finalizers


        Instance Constructors

    Static Constructors

    Destructors (Poorly Named Finalizers)

        Defining Finalizers in C#

        How Finalizers Are Run

        How Finalizers Are Implemented

        Disposal Before Collection: IDisposable


    Chapter 13 Operator Overloading and Conversions


        Defining Operators

        How Operators Are Found

        Nullability and Lifted Operators

        Which Operators Can Be Overloaded?

        Implementing Equality Operations

        How Operators Are Translated


        Built-In Conversions

        User-Defined Conversions

        Other Conversion Mechanisms


    Chapter 14 Object-Oriented Programming

    The Cornerstones of Object Orientation

        A Historical Perspective




        Types in Pictures

    Inheritance for Classes

        Single Inheritance for Classes

        Multiple Inheritance for Interfaces

        Blocking Inheritance

        Hiding Base Class Members

    Protected Accessibility

    Polymorphism and Virtual Members

        Virtual Members

        Overriding Virtual Members

        Declaring Virtual Members

        Sealing and Hiding: Take Two

        How Virtual Dispatch Works

        How Base Calls Work

    Abstract Classes


        Defining Interfaces

        Some Design Recommendations

        Implementing Interfaces


    Chapter 15 Generic Types and Methods

    Life Without Generics

        A Real-World Example with Collections

        Performance Worries

    Getting Started with Generics

    Declaring Generic Types

    Using Generic Types

    Performance Intermezzo

    Operations on Type Parameters

        Default Values

        Getting the Type’s Reflection Info Object

    Generic Constraints

        Interface-Based Constraints

        Base Class Constraints

        Default Constructor Constraint

        Restriction to Value Types or Reference Types

    Generic Methods

    Co- and Contravariance

        Annoyances with Generic Types

        Broken Covariance for Array Types

        Safety Guarantees

        Generic Co- and Contravariance

        Under the Hood

        Where to Use


    Chapter 16 Collection Types

    Nongeneric Collection Types


        Hash Tables




    Generic Collection Types


        SortedDictionary<TKey, TValue> and SortedList<TKey, TValue>

        Queue<T> and Stack<T>

    Other Collection Types


    Chapter 17 Delegates

    Functional Programming

        Historical Perspective

        Programming with Functions

    What Are Delegates?

    Delegate Types

    Delegate Instances

        Anonymous Function Expressions

        Closures: Captured Outer Variables

        Lambda Expressions

        Expression Trees

    Invoking Delegates

    Putting It Together: An Extensible Calculator

    Case Study: Delegates Used in LINQ to Objects

    Asynchronous Invocation

    Combining Delegates


    Chapter 18 Events

    The Two Sides of Delegates

    A Reactive Application

        Using Delegates

        Limitations on Plain Use of Delegates

        Using .NET Events

    How Events Work

    Raising Events, the Correct Way

    Add and Remove Accessors

    Detach Your Event Handlers

    Recommended Event Patterns

        EventHandler and EventArgs


        Designing Events for Use by Derived Classes

    Case Study: INotifyProperty Interfaces and UI Programming

        Events in UI Frameworks

    Countdown, the GUI Way

    Modern Approaches to Reactive Programming

        Events Revisited

        Pull Versus Push

        Dictionary Suggest Revisited


    Chapter 19 Language Integrated Query Essentials

    Life Without LINQ

        In-Memory Data

        Relational Databases


        The Birth of LINQ

    LINQ by Example

        In-Memory Data

        Relational Databases


    Query Expression Syntax

        Why Query Expressions?

        Getting Started

        Source Selection Using a from Clause

        Projection Using the Select Clause

        Filtering Using a where Clause

        Ordering Using the orderby Keyword

        Grouping Using the group by Clause

        Joining Using the join Clause

        Continuing a Query Expression Using the into Clause

        Bindings with the let Clause


    Chapter 20 Language Integrated Query Internals

    How LINQ to Objects Works

        IEnumerable<T> and IEnumerator<T> Recap

        LINQ to Objects Extension Methods


        Lazy Evaluation

        How Iterators Work

    Standard Query Operators

        Source Generators




        Grouping and Joining



        Set Theoretical and Sequencing Operators

        Sequence Persistence

        Remote Versus Local with AsEnumerable

    The Query Pattern

        All About Methods

        Overloading Query Expression Syntax

    Parallel LINQ

        The Cost of Optimization


        How PLINQ Works


        Tweaking Parallel Querying Behavior

        Parallel Enumeration with ForAll

    Expression Trees

        Query Expression Translation

        Homoiconicity for Dummies

        Expression Trees for Query Expressions



    Chapter 21 Reflection

    Typing Revisited, Static and Otherwise

        The Role of Metadata

        The Multilanguage World

        Taking Multilanguage to the Next Level

        How Does All of This Relate to C# Programming?



        A Primer on Application Extensibility

        Reflection for Methods, Properties, Events, and More

        Custom Attributes

    Lightweight Code Generation

        Hello LCG

        A Toy Compiler for Arithmetic Expressions

    Expression Trees

        Compiler-Generated Expression Trees

        The Expression Tree API

        Using the ExpressionTreeVisitor


    Chapter 22 Dynamic Programming

    The dynamic Keyword in C# 4.0

        The dynamic Type

        Dynamic Typing Is Contagious

        Deferred Overload Resolution

        No System.Dynamic Type

        When to Use dynamic: Case Study with IronPython

    DLR Internals

        Dynamic Call Sites and Binders

        Dynamic Dispatch

        Custom Dynamic Objects with DynamicObject

        A Primer to DynamicMetaObject

        Dynamic Operations

        Overall Architecture

    Office and COM Interop

        Essentials of COM Interop

        Simplified COM Interop in .NET 4

        Case Study: COM Interop with Excel and Word


    Chapter 23 Exceptions

    Life Without Exceptions



        Lessons Learned

    Introducing Exceptions

    Exception Handling

        try Statements

        First-Chance Exceptions

        Intermezzo on Historical Debugging with IntelliTrace

        When and What to Catch

        Beyond Your Control

    Throwing Exceptions

    Defining Your Own Exception Types

    (In)famous Exception Types





















    Chapter 24 Namespaces

    Organizing Types in Namespaces

        Once Upon a Time

        Assemblies and Namespaces

    Declaring Namespaces

        Naming Conventions


        Name Clashes Within Namespaces

    Importing Namespaces

        Name Clashes Due to Imports

        Using Aliases

        Extern Aliases

        Extension Methods


    Chapter 25 Assemblies and Application Domains


        Modules and Assemblies

        Types of Assemblies

        Assembly Properties

        Naming, Versioning, and Deployment

        Strong Naming

        The Global Assembly Cache

        Referencing Assemblies

        How Assemblies Get Loaded at Runtime

        Native Image Generation (NGEN)

        Visibility Aspects

        Embedded Resources

        Type Forwarding

        Reflection Flashback

    Application Domains

        Creating Application Domains

        Cross-Domain Communication

        The Managed Add-In Framework


    Part III Working with Base Class Libraries

    Chapter 26 Base Class Library Essentials

    The BCL: What, Where, and How?

        What Is Covered?

        Default Project References

        Namespaces Versus Assemblies

        The System and mscorlib Assemblies

        System.Core’s Story of Red Bits and Green Bits

    The Holy System Root Namespace

        Primitive Value Types

        Working with Arrays

        The Math Class

        BigInteger: Beyond 32-bit and 64-bit Integers

        Complex Numbers

        Generating Random Numbers

        Working with Date and Time

        GUID Values

        Nullability Revisited Briefly

        The Uri Type

        Interacting with the Environment

        Leave the GC Alone (Most of the Time)

        Native Interop with IntPtr

        Lazy Initialization Using Lazy<T>

        Tuple Types

    Facilities to Work with Text

        Formatting Text

        Parsing Text to Objects

        Regular Expressions

        Commonly Used String Methods

        The StringBuilder Class

        Text Encoding


    Chapter 27 Diagnostics and Instrumentation

    Ensuring Code Quality

        Code Analysis

        Asserts and Contracts

        Diagnostic Debugger Output

        Controlling the Debugger

        Logging Stack Traces

        Measuring Performance Using StopWatch


        Using Event Logs

        Monitoring with Performance Counters

        Other Manageability Frameworks

    Controlling Processes

        Querying Process Information

        Starting Processes


    Chapter 28 Working with I/O

    Files and Directories

        Listing Drives

        Working with Directories

        Working with Paths

        The FileInfo Class

    Monitoring File System Activity

    Readers and Writers

        The File Class

        TextReader and TextWriter

    Streams: The Bread and Butter of I/O

        Memory Streams

        Working with Files: Take Two

        BinaryReader and BinaryWriter

        Asynchronous Read and Write Operations

        Streams Are Everywhere

    A Primer to (Named) Pipes

    Memory-Mapped Files in a Nutshell

    Overview of Other I/O Capabilities


    Chapter 29 Threading and Synchronization

    Using Threads

        Explaining the Concept of Threads

        The Managed Code Story

        Where It All Starts: The Thread Class

        More About a Thread’s Life Cycle

        Managed Thread Characteristics

        Dealing with Exceptions

        Thread-Specific State

        Essential Threading Debugging


    Thread Pools

        .NET’s Thread Pool

    Synchronization Primitives

        Atomicity (or Lack Thereof) Illustrated

        Monitors and the lock Keyword



        More Advanced Locks

        Signaling with Events

        Interlocked Helpers

        More Synchronization Mechanisms



    Chapter 30 Task Parallelism and Data Parallelism

    Pros and Cons of Threads

        Cutting Costs

        An Ideal Number of Threads?

    The Task Parallel Library


        Declarative Versus Imperative

        What Are Tasks?

    Task Parallelism

        Creating and Starting Tasks

        Retrieving a Task’s Result

        Dealing with Errors


        Cancellation of Tasks

        Parallel Invocation

        Waiting for Multiple Tasks

        How the Task Scheduler Works

    Data Parallelism

        Parallel For Loops

        Parallel Foreach Loops


    9780672330797    TOC    12/16/2010


    Submit Errata

    More Information

    Unlimited one-month access with your purchase
    Free Safari Membership