Gift Guide

C# 4.0 Unleashed [NOOK Book]


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 ...

See more details below
C# 4.0 Unleashed

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$25.49 price
(Save 42%)$43.99 List Price


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
Read More Show Less

Product Details

  • ISBN-13: 9780132681728
  • Publisher: Pearson Education
  • Publication date: 1/18/2011
  • Series: Unleashed
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 1080
  • File size: 69 MB
  • Note: This product may take a few minutes to download.

Meet the Author

Bart J.F. De Smet is a software development engineer on Microsoft’s Cloud Programmability Team, an avid blogger, and a popular speaker at various international conferences. In his current role, he’s actively involved in the design and implementation of Reactive Extensions for .NET (Rx) and on an extended “LINQ to Anything” mission. You can read about Bart’s technical adventures on his blog at

His main interests include programming languages, virtual machines and runtimes, functional programming, and all sorts of theoretical foundations. In his spare time, Bart likes to hike in the wonderful nature around Seattle, read technical books, and catch up on his game of snooker.

Before joining Microsoft in October 2007, Bart was active in the .NET community as a Microsoft Most Valuable Professional (MVP) for C#, while completing his Bachelor of Informatics, Master of Informatics, and Master of Computer Science Engineering studies at Ghent University, Belgium.

Read More Show Less

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>


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


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

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

Read More Show Less

Customer Reviews

Average Rating 5
( 1 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted April 6, 2011

    No text was provided for this review.

Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)