Accelerated C# 2008

Trey Nash

Many books introduce C#, but if you don't have the time to read 1200 pages, Accelerated C# 2008 gives you everything you need to know about C# 2008 in a concentrated 500 pages of must-know information and best practices.

  • Published on Jun 25 2008
  • Pages 500
  • Downloaded 31
  • Type PDF
Download Download Source Code
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 14.1k
  • 0



Many books introduce C#, but if you don't have the time to read 1200 pages, Accelerated C# 2008 gives you everything you need to know about C# 2008 in a concentrated 500 pages of must-know information and best practices.

C# 2008 offers powerful new features, and Accelerated C# 2008 is the fastest path to mastery, for both experienced C# programmers moving to C# 2008 and programmers moving to C# from another object-oriented language.

You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?

  • Comprehensively and concisely explains both C# 2005 and C# 2008 features
  • Focuses on the language itself and on how to use C# 2008 proficiently for all .NET application development
  • Concentrates on how C# features work and how to best use them for robust, high–performance code.

What you’ll learn

  • How C# works with and exploits the CLR
  • How to use arrays, collections, and iterators
  • How to handle events with delegates and anonymous functions
  • How to design and use generic types and methods
  • How to thread efficiently and robustly
  • How to use the C# 2008 anonymous types, lamba expressions, and extension methods

Who is this book for?

If you’re an experienced C# programmer, you need to understand how C# has changed with C# 2008. If youre an experienced object–oriented programmer moving to C#, you want to ramp up quickly in the language while learning the latest features and techniques. In either case, this book is for you. The first three chapters succinctly present C# fundamentals, for those new to or reviewing C#. The rest of the book covers all the major C# features, in great detail, explaining how they work and how best to use them. Whatever your background or need, youll treasure this book for as long as you code in C# 2008.

Author Information

Trey Nash is a principal software engineer working on PC Bluetooth solutions at Cambridge Silicon Radio. Before focusing on .NET, he specialized in COM/DCOM programming in C, C++, and ATL. Trey earned his bachelor of science and master of engineering degrees in electrical engineering from Texas A&M University.

What is in this book


About the Author
About the Technical Reviewer

CHAPTER 1: C# Preview

Differences Between C# and C++
          C# 1
          CLR Garbage Collection
Example of a C# Program
Overview of Features Added in C# 2.0
Overview of What’s New in C# 3.0

CHAPTER 2: C# and the CLR

The JIT Compiler in the CLR
Assemblies and the Assembly Loader
          Minimizing the Working Set of the Application
          Naming Assemblies
          Loading Assemblies
Cross-Language Compatibility

CHAPTER 3: C# Syntax Overview

C# Is a Strongly Typed Language
Statements and Expressions
Types and Variables
          Value Types
          Reference Types
          Default Variable Initialization
          Implicitly Typed Local Variables
          Type Conversion
          as and is Operators
          Defining Namespaces
          Using Namespaces
Control Flow
          if-else, while, do-while, and for
          break, continue, goto, return, and throw

CHAPTER 4: Classes, Structs, and Objects

Class Definitions
          sealed Classes
          abstract Classes
          Nested Classes
          partial Classes
          partial Methods
          Static Classes
          Reserved Member Names
Value Type Definitions
          The Meaning of this
Anonymous Types
Object Initializers
Boxing and Unboxing
          When Boxing Occurs
          Efficiency and Confusion
          Equality and What It Means
          The IComparable Interface
Creating Objects
          The new Keyword
          Field Initialization
          Static (Class) Constructors
          Instance Constructor and Creation Ordering
Destroying Objects
          Deterministic Destruction
          Exception Handling
Disposable Objects
          The IDisposable Interface
          The using Keyword
Method Parameter Types
          Value Arguments
          ref Arguments
          out Parameters
          param Arrays
Method Overloading
Inheritance and Virtual Methods
          Virtual and Abstract Methods
          override and new Methods
          sealed Methods
          A Final Few Words on C# Virtual Methods
Inheritance, Containment, and Delegation
          Choosing Between Interface and Class Inheritance
          Delegation and Composition vs. Inheritance

CHAPTER 5: Interfaces and Contracts

Interfaces Define Types
Defining Interfaces
          What Can Be in an Interface?
          Interface Inheritance and Member Hiding
Implementing Inter
          Implicit Interface Implementation
          Explicit Interface Implementation
          Overriding Interface Implementations in Derived Classes
          Beware of Side Effects of Value Types Implementing Interfaces
Interface Member Matching Rules
Explicit Interface Implementation with Value Types
Versioning Considerations
          Contracts Implemented with Classes
          Interface Contracts
Choosing Between Interfaces and Classes

CHAPTER 6: Overloading Operators

Just Because You Can Doesn’t Mean You Should
Types a
nd Formats of Overloaded Operators
Operators Shouldn’t Mutate Their Operands
Does Parameter Order Matter?
Overloading the Addition Operator
Operators That Can Be Overloaded
          Comparison Operators
          Conversion Operators
          Boolean Operators

CHAPTER 7: Exception Handling and Exception Safety

How the CLR Treats Exceptions
Mechanics of Handling Exceptions in C#
          Throwing Exceptions
          Changes with Unhandled Exceptions Starting with .NET 2.0
          Syntax Overview of the try Statement
          Rethrowing Exceptions and Translating Exceptions
          Exceptions Thrown in finally Blocks
          Exceptions Thrown in Finalizers
          Exceptions Thrown in Static Constructors
Who Should Handle Exceptions?
Avoid Using Exceptions to Control Flow
Achieving Exception Neutrality
          Basic Structure of Exception-Neutral Code
          Constrained Execution Regions
          Critical Finalizers and SafeHandle
Creating Custom Exception Classes
Working with Allocated Resources and Exceptions
Providing Rollback Behavior

CHAPTER 8: Working with Strings

String Overview
Format Specifiers and Globalization
          Object.ToString, IFormattable, and CultureInfo
          Creating and Registering Custom CultureInfo Types
          Format Strings
          Console.WriteLine and String.Format
          Examples of String Formatting in Custom Types
          Comparing Strings
Working with Strings from Outside Sources
Searching Strings with Regular Expressions
          Searching with Regular Expressions
          Searching and Grouping
          Replacing Text with Regex
          Regex Creation Options

CHAPTER 9: Arrays, Collection Types, and Iterators

Introduction to Arrays
          Implicitly Typed Arrays
          Type Convertibility and Covariance
          Sortability and Searchability
          Vectors vs. Arrays
Multidimensional Rectangular Arrays
Multidimensional Jagged Arrays
Collection Types
          Comparing ICollection with ICollection
          Collection Synchronization
IEnumerable <T>, IEnumerator <T>, IEnumerable, and IEnumerator
          Types That Produce Collections
          Forward, Reverse, and Bidirectional Iterators
Collection Initializers

CHAPTER 10: Delegates, Anonymous Functions, and Events

Overview of Delegates
Delegate Creation and Use
          Single Delegate
          Delegate Chaining
          Iterating Through Delegate Chains
          Unbound (Ope
n Instance) Delegates
Anonymous Methods
          Beware the Captured Variable Surprise
          Anonymous Methods as Delegate Parameter Binders
The Strategy Pattern

CHAPTER 11: Generics

Difference Between Generics and C++ Templates
Efficiency and Type Safety
of Generics
Generic Type Definitions and Constructed Types
          Generic Classes and Structs
          Generic Interfaces
          Generic Methods
          Generic Delegates
          Generic Type Conversion
          Default Value Expression
          Nullable Types
          Constructed Types Control Accessibility
          Generics and Inheritance
          Constraints on Nonclass Types
Generic System Collections
Generic System Interfaces
Select Problems and Solutions
          Conversion and Operators Within Generic Types
          Creating Constructed Types Dynamically

CHAPTER 12: Threading in C#

Threading in C# and .NET
          Starting Threads
          The IOU Pattern and Asynchronous Method Calls
          States of a Thread
          Terminating Threads
          Halting Threads and Waking Sleeping Threads
          Waiting for a Thread to Exit
          Foreground and Background Threads
          Thread-Local Storage
          How Unmanaged Threads and COM Apartments Fit In
Synchronizing Work Between Threads
          Lightweight Synchronization with the Interlocked Class
          Monitor Class
          Locking Objects
          Win32 Synchronization Objects and WaitHandle
Using ThreadPool
          Asynchronous Method Calls

CHAPTER 13: In Search of C# Canonical Forms

Reference Type Canonical Forms
          Default to sealed Classes
          Use the Non-Virtual Interface (NVI) Pattern
          Is the Object Cloneable?
          Is the Object Disposable?
          Does the Object Need a
          What Does Equality Mean for This Object?
          If You Override Equals, Override GetHashCode Too
          Does the Object Support Ordering?
          Is the Object Formattable?
          Is the Object Convertible?
          Prefer Type Safety at All Times
          Using Immutable Reference Types
Value Type Canonical Forms
          Override Equals for Better Performance
          Do Values of This Type Support Any Interfaces?
          Implement Type-Safe Forms of Interface Members and Derived Methods
          Checklist for Reference Types
          Checklist for Value Types

CHAPTER 14: Extension Methods

Introduction to Extension Methods
          How Does the Compiler Find Extension Methods?
          Under the Covers
          Code Readability vs. Code Understandability
Recommendations for Use
          Consider Extension Methods Over Inheritance
          Isolate Extension Methods in Separate Namespace
          Changing a Type’s Contract Can Break Extension Methods
Operation Chaining
Custom Iterators
          Borrowing from Functional Programming
The Visitor Pattern

CHAPTER 15: Lambda Expressions

Introduction to Lambda Expressions
          Lambda Expressions
          Lambda Statements
Expression Trees
          Operating on Expressions
          Functions As Data
Useful Applications of Lambda Expressions
          Iterators and Generators Revisited
          Closures (Variable Capture) and Memoization
          Anonymous Recursion

CHAPTER 16 LINQ: Language Integrated Query

A Bridge to Data
          Query Expressions
          Extension Methods and Lambda Expressions Revisited
Standard Query Operators
C# Query Keywords
          The from Clause and Range Variables
          The join Clause
          The where Clause a
nd Filters
          The orderby Clause
          The select Clause and Projection
          The let Clause
          The group Clause
          The into Clause and Continuations
The Virtues of Being Lazy
          C# Iterators Foster Laziness
          Subverting Laziness
          Executing Queries Immediately
          Expression Trees Revisited
Techniques from Functional Programming
          Custom Standard Query Operators and Lazy Evaluation
          Replacing foreach Statements

APPENDIX References




Mindcracker Network accepts no liability for providing the customer with the hard copy of the book purchased. Mindcracker is not responsible for any dispute relating to the above. All eBooks listed in this section are in "PDF" Format. Contact [email protected] for further assistant.