C# 4.0 Unleashed - Bart De Smet

C# 4.0 Unleashed

(Autor)

Buch | Softcover
1648 Seiten
2011
Sams Publishing (Verlag)
978-0-672-33079-7 (ISBN)
56,60 inkl. MwSt
zur Neuauflage
  • Titel ist leider vergriffen;
    keine Neuauflage
  • Artikel merken
Zu diesem Artikel existiert eine Nachauflage
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

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 http://blogs.bartdesmet.net/bart.   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.  

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

    Interfaces

    Delegates

    Members

    A Note on Generics

    The Role of the Common Language Specification

Executing Managed Code

    The Assembly Manifest

    IL Code

    Metadata

    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

Summary

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

    Multiparadigm

    Language-Shaping Forces

    Compiler as a Service

    Taming the Concurrency Beast

Summary

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

    Editions

    Expression

    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

    Designers

    Server Explorer

    Database Mappers

    Unit Testing

    Team Development

Summary

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

Keywords

    Contextual Keywords

    Syntax Highlighting in Visual Studio

A Primer on Types

    Code and Data

    Types, Objects, and Instances

    Variables

    Classes and Other Types

Built-In Types

    Integral Types

    Floating-Point Types

    The Decimal Type

    The Boolean Type

    The String Type

    Object

    Dynamic Typing

    A Word on CLS Compliance

    A Matter of Style: Aliases or Not?

Local Variables

    Declaration

    Scope

    Assignment

    Constants

    Implicitly Typed Local Variable Declarations

Intermezzo on Comments

    Single-Line Comments

    A Primer to Preprocessing Directives

    Delimited Comments

    Documentation Comments

Arrays

    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

Summary

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

    Associativity

Null-Coalescing Operator

Assignment

    Decaration Versus (Simple) Assignment

    Compound Assignment

    A Gentle Introduction to Definite Assignment

    Postfix and Prefix Increment and Decrement Operators

Summary

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

Summary

Chapter 7 Simple Control Flow

What Are Statements, Anyway?

Expression Statements

    Method Calls

    Assignments

    Pre- and Post-Increment/Decrement

The Empty Statement

Blocks

Declarations

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

Summary

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

Summary

Chapter 9 Introducing Types

Types Revisited

Classes Versus Structs

    References Versus Values

    Heap Versus Stack

    Boxing

    The Dangers of Mutable Value Types

Type Members

    Visibility

    Static Versus Instance

    Partial Types

Summary

Chapter 10 Methods

Defining Methods

Return Type

Parameters

    Value Parameters

    Reference Parameters

    Output Parameters

    Parameter Arrays

    Optional and Named Parameters

Overloading

    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

Refactoring

Code Analysis

Summary

Chapter 11 Fields, Properties, and Indexers

Fields

    Declaring Fields

    Accessing Fields

    Initializing Fields

    Read-Only Fields

    Constants

    Volatile Fields

An Intermezzo About Enums

    Why Enums Matter

    Underlying Types

    Assigning Values to Members

    The System.Enum Type

    Flags

    Revisiting the switch Statement

    Behind the Scenes

Properties

    Declaring and Using Properties

    Auto-Implemented Properties

    How Properties Work

Indexers

    Defining Indexers

    How Indexers Are Implemented

Summary

Chapter 12 Constructors and Finalizers

Constructors

    Instance Constructors

Static Constructors

Destructors (Poorly Named Finalizers)

    Defining Finalizers in C#

    How Finalizers Are Run

    How Finalizers Are Implemented

    Disposal Before Collection: IDisposable

Summary

Chapter 13 Operator Overloading and Conversions

Operators

    Defining Operators

    How Operators Are Found

    Nullability and Lifted Operators

    Which Operators Can Be Overloaded?

    Implementing Equality Operations

    How Operators Are Translated

Conversions

    Built-In Conversions

    User-Defined Conversions

    Other Conversion Mechanisms

Summary

Chapter 14 Object-Oriented Programming

The Cornerstones of Object Orientation

    A Historical Perspective

    Encapsulation

    Inheritance

    Polymorphism

    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

Interfaces

    Defining Interfaces

    Some Design Recommendations

    Implementing Interfaces

Summary

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

Summary

Chapter 16 Collection Types

Nongeneric Collection Types

    ArrayList

    Hash Tables

    Queue

    Stack

    Summary

Generic Collection Types

    List

    SortedDictionary and SortedList

    Queue and Stack

Other Collection Types

Summary

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

Summary

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

    EventHandler

    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

Summary

Chapter 19 Language Integrated Query Essentials

Life Without LINQ

    In-Memory Data

    Relational Databases

    XML

    The Birth of LINQ

LINQ by Example

    In-Memory Data

    Relational Databases

    XML

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

Summary

Chapter 20 Language Integrated Query Internals

How LINQ to Objects Works

    IEnumerable and IEnumerator Recap

    LINQ to Objects Extension Methods

    Iterators

    Lazy Evaluation

    How Iterators Work

Standard Query Operators

    Source Generators

    Restriction

    Projection

    Ordering

    Grouping and Joining

    Aggregation

    Predicates

    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

    AsParallel

    How PLINQ Works

    AsOrdered

    Tweaking Parallel Querying Behavior

    Parallel Enumeration with ForAll

Expression Trees

    Query Expression Translation

    Homoiconicity for Dummies

    Expression Trees for Query Expressions

    IQueryable

Summary

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?

Reflection

    System.Type

    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

Summary

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

Summary

Chapter 23 Exceptions

Life Without Exceptions

    Win32

    COM

    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

    DivideByZeroException

    OverflowException

    NullReferenceException

    IndexOutOfRangeException

    InvalidCastException

    ArrayTypeMismatchException

    TypeInitializationException

    ObjectDisposedException

    OutOfMemoryException

    StackOverflowException

    ExecutionEngineException

    ArgumentException

    ArgumentNullException

    ArgumentOutOfRangeException

    InvalidOperationException

    NotImplementedException

    NotSupportedException

    FormatException

    AggregateException

Summary

Chapter 24 Namespaces

Organizing Types in Namespaces

    Once Upon a Time

    Assemblies and Namespaces

Declaring Namespaces

    Naming Conventions

    Visibility

    Name Clashes Within Namespaces

Importing Namespaces

    Name Clashes Due to Imports

    Using Aliases

    Extern Aliases

    Extension Methods

Summary

Chapter 25 Assemblies and Application Domains

Assemblies

    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

Summary

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

Summary

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

Instrumentation

    Using Event Logs

    Monitoring with Performance Counters

    Other Manageability Frameworks

Controlling Processes

    Querying Process Information

    Starting Processes

Summary

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

Summary

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

    Techniques

Thread Pools

    .NET’s Thread Pool

Synchronization Primitives

    Atomicity (or Lack Thereof) Illustrated

    Monitors and the lock Keyword

    Mutexes

    Semaphores

    More Advanced Locks

    Signaling with Events

    Interlocked Helpers

    More Synchronization Mechanisms

    BackgroundWorker

Summary

Chapter 30 Task Parallelism and Data Parallelism

Pros and Cons of Threads

    Cutting Costs

    An Ideal Number of Threads?

The Task Parallel Library

    Architecture

    Declarative Versus Imperative

    What Are Tasks?

Task Parallelism

    Creating and Starting Tasks

    Retrieving a Task’s Result

    Dealing with Errors

    Continuations

    Cancellation of Tasks

    Parallel Invocation

    Waiting for Multiple Tasks

    How the Task Scheduler Works

Data Parallelism

    Parallel For Loops

    Parallel Foreach Loops

Summary

 

 

9780672330797    TOC    12/16/2010

 

Erscheint lt. Verlag 20.1.2011
Verlagsort Indianapolis
Sprache englisch
Maße 180 x 226 mm
Gewicht 1948 g
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
ISBN-10 0-672-33079-2 / 0672330792
ISBN-13 978-0-672-33079-7 / 9780672330797
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich
Das Handbuch für Webentwickler

von Philip Ackermann

Buch | Hardcover (2023)
Rheinwerk (Verlag)
49,90
Grundlagen und praktische Anwendungen von Transpondern, kontaktlosen …

von Klaus Finkenzeller

Buch (2023)
Hanser (Verlag)
89,99
das umfassende Handbuch

von Marc Marburger

Buch | Hardcover (2024)
Rheinwerk (Verlag)
49,90