Accelerated C# 2010

By Trey Nash

Accelerated C# 2010 Cover Image

C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language.

Full Description

  • ISBN13: 978-1-4302-2537-9
  • User Level: Intermediate to Advanced
  • Publication Date: January 14, 2010
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $39.99
  • eBook Price: $27.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language. Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR). This book teaches both core C# language concepts and how to wisely employ C# idioms and object-oriented design patterns to exploit the power of C# and the CLR.

This book is both a rapid tutorial and a permanent reference. 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 from the start?

  • Comprehensively and concisely explains both C# 2008 and C# 2010 features
  • Focuses on the language itself and on how to use C# 2010 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 C# anonymous types, lamba expressions, and extension methods work and how to use them

Who this book is for

If you're an experienced C# programmer, you need to understand how C# has changed with C# 2010. If you're 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, you’ll treasure this book for as long as you code in C# 2010.

Table of Contents

Table of Contents

  1. C# Preview
  2. C# and the CLR
  3. C# Syntax Overview
  4. Classes, Structs, and Objects
  5. Interfaces and Contracts
  6. Overloading Operators
  7. Exception Handling and Exception Safety
  8. Working with Strings
  9. Arrays, Collection Types, and Iterators
  10. Delegates, Anonymous Functions, and Events
  11. Generics
  12. Threading in C#
  13. In Search of C# Canonical Forms
  14. Extension Methods
  15. Lambda Expressions
  16. LINQ: Language Integrated Query
  17. Dynamic Types
Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

Please Login to submit errata.

On page 34:
"The better approach is to follow the idiom of applying the as operator to obtain a reference of the variable with the desired type, and then test whether the resulting reference IS NULL, which would mean that the
conversion SUCCEEDED."

It seems we should test if the reference IS NOT NULL, instead.

On page 87:
Trey Nash gives the example that shouldn't compile yet it does work correctly. It's the example with usage of this without params. Tested on msvc2010.

public struct ComplexNumber
{
public ComplexNumber( double real, double imaginary )
{
this.real = real;
this.imaginary = imaginary;
}
public ComplexNumber( double real )
:this()
{
this.real = real;
}
private double real;
private double imaginary;
}

On page 143:
// this doesn't compile

public interface IUIControl
{
void Paint() ;
}

public class StaticText : IUIControl
{
public void Paint(); //Notice that we’ve added ‘public’ to the method declaration
}

On page 151 :
public class EntryPoint
{
static void Main() {
B b1 = new B();

C c1 = new C();
B b2 = c1;

b1. Go() ;
c1. Go() ;
b2. Go() ;
((I)b2) .Go(); // cast should be IMyInterface
}
}