Print this page Share

Professional C# 2008

ISBN: 978-0-470-19137-8
1848 pages
March 2008
Professional C# 2008  (0470191376) cover image


Professional C# 2008 starts by reviewing the overall architecture of .NET in Chapter 1 in order to give you the background you need to be able to write managed code. After that the book is divided into a number of sections that cover both the C# language and its application in a variety of areas.

See More

Table of Contents

Acknowledgments xiii

Introduction xlvii

Part I: The C# Language 1

Chapter 1: .NET Architecture 3

Chapter 2: C# Basics 25

Chapter 3: Objects and Types 75

Chapter 4: Inheritance 101

Chapter 5: Arrays 121

Chapter 6: Operators and Casts 141

Chapter 7: Delegates and Events 177

Chapter 8: Strings and Regular Expressions 203

Chapter 9: Generics 223

Chapter 10: Collections 247

Chapter 11: Language Integrated Query 297

Chapter 12: Memory Management and Pointers 329

Chapter 13: Reflection 357

Chapter 14: Errors and Exceptions 377

Part II: Visual Studio 399

Chapter 15: Visual Studio 2008 401

Chapter 16: Deployment 443

Part III: Base Class Libraries 467

Chapter 17: Assemblies 469

Chapter 18: Tracing and Events 509

Chapter 19: Threading and Synchronization 533

Chapter 20: Security 583

Chapter 21: Localization 639

Chapter 22: Transactions 679

Chapter 23: Windows Services 715

Chapter 24: Interoperability 749

Part IV: Data 789

Chapter 25: Manipulating Files and the Registry 791

Chapter 26: Data Access 845

Chapter 27: LINQ to SQL 895

Chapter 28: Manipulating XML 921

Chapter 29: LINQ to XML 967

Chapter 30: .NET Programming with SQL Server 985

Part V: Presentation 1015

Chapter 31: Windows Forms 1017

Chapter 32: Data Binding 1061

Chapter 33: Graphics with GDI+ 1093

Chapter 34: Windows Presentation Foundation 1149

Chapter 35: Advanced WPF 1199

Chapter 37: ASP.NET Pages 1273

Chapter 38: ASP.NET Development 1311

Chapter 39: ASP.NET AJAX 1355

Chapter 40: Visual Studio Tools for Office 1385

Part VI: Communication 1421

Chapter 41: Accessing the Internet 1423

Chapter 42: Windows Communication Foundation 1455

Chapter 43: Windows Workflow Foundation 1487

Chapter 44: Enterprise Services 1527

Chapter 45: Message Queuing 1555

Chapter 46: Directory Services 1587

Chapter 47: Peer-to-Peer Networking 1625

Chapter 48: Syndication 1643

Part VII: Appendices 1653

Appendix A: ADO.NET Entity Framework 1655

Appendix B: C#, Visual Basic, and C++/CLI 1681

Summary 1729

Index 1731

See More

Author Information

Christian Nagel of thinktecture is a software architect and developer who offers training and consulting on how to design and develop Microsoft .NET solutions. He looks back on more than 20 years of software development experience. Christian started his computing career with PDP 11 and VAX/VMS platforms, covering a variety of languages and platforms. Since the year 2000, when .NET was just a technology preview, he has been working with various .NET technologies to build numerous .NET solutions. With his profound knowledge of Microsoft technologies, he has written numerous .NET books, and is certified as a Microsoft Certified Trainer and Professional Developer for ASP.NET. Christian speaks at international conferences such as TechEd and Tech Days, and supports .NET user groups with INETA Europe. You can contact Christian via his Web sites, www.christiannagel.com and www.thinktecture.com .

Bill Evjen, Microsoft MVP is an active proponent of .NET Technologies and community - based learning initiatives for .NET. He has been actively involved with .NET since the first bits were released in 2000. In the same year, Bill founded the St. Louis .NET User Group ( www.stlnet.org ), one of the world ’ s first such groups. Bill is also the founder and former executive director of the International .NET Association ( www.ineta.org ), which represents more than 450,000 members worldwide. Based in St. Louis, Missouri, Bill is an acclaimed author (more than 15 books to date) and speaker on ASP.NET and SML Web services. In addition to writing and speaking at conferences such as DevConnections, VSLive, and TechEd, Bill works closely with Microsoft as a Microsoft regional director. Bill is the technical architect for Lipper ( www.lipperweb.com ), a wholly owned subsidiary of Reuters, the international news and financial services company. He graduated from Western Washington University in Bellingham, Washington with a Russian language degree. When he isn ’ t tinkering on the computer, he can usually be found at his summer house in Toivakka, Finland. You can reach Bill at evjen@yahoo.cpm.

Morgan Skinner began his computing career at a young age on the Sinclair ZX80 at school, where he was underwhelmed by some code a teacher had written and so began programming in assembly language. Since then he ’ s used all sorts of languages and platforms, including VAX Macro Assembler, Pascal, Modula2, Smalltalk, X86 assembly language, PowerBuilder, C/C++, VB, and currently C# (of course). He ’ s been programming in .NET since the PDC release in 2000, and liked it so much he joined Microsoft in 2001. He now works in premier support for developers and spends most of his time assisting customers with C#. You can reach Morgan at www.morganskinner.com.

Jay Glynn started writing software nearly 20 years ago, writing applications for the PICK operating system using PICK basic. Since then, he has created software using Paradox PAL and Object PAL, Delphi, VBA, Visual Basic, C, C++, Java, and of course, C#. He is currently a project coordinator and architect for a large financial services company in Nashville, Tennessee, working on software for the TabletPC platform. You can contact Jay at jlsglynn@hotmail.com.

Karli Watson is a freelance author and a technical consultant of 3form Ltd ( www.3form.net ) and Boost .net, and an associate technologist at Content Master ( www.contentmaster.com ). He started out with the intention of becoming a world - famous nanotechnologist, so perhaps one day you might recognize his name as he receives a Nobel Prize. For now, though, Karli ’ s main academic interest is the .NET Framework, and all the boxes of tricks it contains. A snowboarding enthusiast, Karli also loves cooking, spends far too much time playing Anarchy Online and EVE, and wishes he had a cat. As yet, nobody has seen fit to publish Karli ’ s first novel, but the rejection letters make an attractive pile. If he ever puts anything up there, you can visit Karli online at http://www.karliwatson.com.

See More


Download TitleSizeDownload
README FIRST 2.46 KB Click to Download
Chapter 1 - No code    
Chapter 2 13.71 KB Click to Download
Chapter 3 8.34 KB Click to Download
Chapter 4 4.61 KB Click to Download
Chapter 5 88.41 KB Click to Download
Chapter 6 9.55 KB Click to Download
Chapter 7 263.36 KB Click to Download
Chapter 8 3.84 KB Click to Download
Chapter 9 149.88 KB Click to Download
Chapter 10 226.21 KB Click to Download
Chapter 11 116.27 KB Click to Download
Chapter 12 11.46 KB Click to Download
Chapter 13 11.14 KB Click to Download
Chapter 14 1.96 KB Click to Download
Chapter 15 - No code 292 bytes Click to Download
Chapter 16 73.13 KB Click to Download
Chapter 17 152.28 KB Click to Download
Chapter 18 188.28 KB Click to Download
Chapter 19 449.73 KB Click to Download
Chapter 20 596.22 KB Click to Download
Chapter 21 660.13 KB Click to Download
Chapter 22 444.88 KB Click to Download
Chapter 23 651.02 KB Click to Download
Chapter 24 22.29 MB Click to Download
Chapter 25 106.88 KB Click to Download
Chapter 26 23.91 KB Click to Download
Chapter 27 978.82 KB Click to Download
Chapter 28 76.70 KB Click to Download
Chapter 29 1.03 MB Click to Download
Chapter 30 149.47 KB Click to Download
Chapter 31 368.10 KB Click to Download
Chapter 32 186.37 KB Click to Download
Chapter 33 200.24 KB Click to Download
Chapter 34 783.38 KB Click to Download
Chapter 35 742.13 KB Click to Download
Chapter 36 238.35 KB Click to Download
Chapter 37 489.16 KB Click to Download
Chapter 38 8.92 MB Click to Download
Chapter 39 286.47 KB Click to Download
Chapter 40 92.38 KB Click to Download
Chapter 41 20.79 KB Click to Download
Chapter 42 461.03 KB Click to Download
Chapter 43 424.49 KB Click to Download
Chapter 44 179.80 KB Click to Download
Chapter 45 399.12 KB Click to Download
Chapter 46 125.16 KB Click to Download
Chapter 47 29.91 KB Click to Download
Chapter 48 113.81 KB Click to Download
Appendix A - No code    
Appendix B 2.33 MB Click to Download
Appendix C 179.63 KB Click to Download
All Code for Book 45.09 MB Click to Download
Chapter 30 Database
Database file first referenced on page 986.
153.03 KB Click to Download
Missing Database Files for Chapter 22
134.70 KB Click to Download
Additional Downloadable Code
This is a missing piece of downloadable code. It is a database file referenced first on page 986.
153.03 KB Click to Download
See More


Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
liv Errors in Reference
2nd row from top:
Visual Studio 2005

should be:
Visual Studio 2008


4th row from top:
Framework 2.0 or 3.0

should be:
Framework 2.0, 3.0 or 3.5
L (50 in Intro) Error in Text
Page L of the introduction referencing automatically implemented properties supplies the fully expanded example using myItem.

The field declaration is a private int _myItem, while the property accessor and mutator refer to myItem (no underscore). They should be:

private int myItem;
7 Error in Text

should be:

2 26 Error in Reference
Reference is made to an online document here:

We have also made available separate documents for download on the Wrox Press Web site (www.wrox.com) that give introductions to C# from the point of view of each of these languages. Should be: We have made introductions to C# from the point of view of each of these languages available in Appendix B.
31 Error in Text
Under "The output from this program is," on the third line:


Should be

33 Errore in Code
The Console.WriteLine() statement should not be outside of a method.
42 Error in Text
Near the bottom of the page,

... to Visual Basic EndIf...

Should be

... to Visual Basic End If...

(missing space)
2 43 Error in Code
In the second code listing:

if (i == 0) Let's add some brackets here.

The "Let's add some brackets here." comment should not be there. Should be:

if (i == 0)
66, 67 Error in Text
On pages 66 and 67, there are reserved keyboards listed. Private and Public are both capitalized, which should be lowercase. Any C# keyword should be lowercase.
2 69 Error in Text
public int subscriberId;

Should be

private int subscriberId;
88 Error in Code
The paragraph at the bottom of the page has two errors:


should read:




should read:

112 Error in Table
The table should read:

internal Any types or members
private Any member of a type, also any nested type
4 119 Error in Code
if ((result == Withdraw(amount))

should read:
if (result = Withdraw(amount))
126 Error in Code
row: 2, element: 1, value: 9
row: 2, element: 2, value: 10
row: 2, element: 3, value: 11

Should be:
row: 2, element: 0, value: 9
row: 2, element: 1, value: 10
row: 2, element: 2, value: 11
129 Error in Text
The Array class implements a bubble-sort for sorting the elements

Should be

The Array class implements a quick-sort algorithm for sorting the elements
142 Error in Table
Line 6 of the table

Comparison == != < ><= >=

should be

Comparison == != < > <= >= (space between > and <=)
148 Error in Table
In line 5 of the table:

Group Operators

can be removed, is same as header
7 192 Error in Code
bottom line:

list.FindAll(int x) => { return x>5; });

Should be:

list.FindAll((int x) => { return x>5; });
148 Error in Table
In line 8 of table:

Relational < ><= >= is as

should be

Relational < > <= >= is as (space between > and <=)
163 Error in Table
In line 5 of the table:

Comparison ==, !=,>=,<=>,<,

should be

Comparison ==, !=, >=, <=, >, < (comma between <= and >; the last comma can be removed; add space for readability)
197 Typo in Text
Before the last code:

The code for the events would like this:

should be

The code for the events would be like this:
198 Error in Code
"public ActionCancelEventArgs(bool cancel) : this(false, String.Empty) {}"

should be:

"public ActionCancelEventArgs(bool cancel) : this(cancel, String.Empty)
200 Error in Text
First paragraph:

set the string to :: and cancel the event

should be

set the string to "" and cancel the event
212-214 Error in Code
On page 214, the routine Norm() should look like this:

public double Norm()


return Math.Sqrt(x*x + y*y + z*z);

10 260 Error in Text
return res;

?res? should be changed to ?result?
271 Error in Figure 10-4
Figure 10-4 should have:

List<LinkedListNode<Document>> for the list on the left column and

LinkedList<Document> for the linked list on the right column
274 Error in Text
After this line of code:

firstPriorityNode = priorityNode.Previous;

The following line should be added:

priorityNode = firstPriorityNode;
315 Error in Text
List for the grouping query on page 315 is incorrect.

List should be:

UK 9
Brazil 3
Finland 3
Australia 2
Austria 2
Italy 2
10 316 Error in Results
Lewis Hamilton should be removed from the results on bottom of page 316, Kimi Raikkonen should be added to the Finland-results.

Here are the correct results:

UK 8
Jim Clark; Mike Hawthorn; Graham Hill; Damon Hill; James Hunt; Nigel Mansell; Jackie Stewart; John Surtees;
Brazil 3
Emerson Fittipaldi; Nelson Piquet; Ayrton Senna;
Finland 3
Mika Hakkinen; Kimi Raikkonen; Keke Rosberg;
Australia 2
Jack Brabham; Alan Jones;
Austria 2
Niki Lauda; Jochen Rindt;
Italy 2
Alberto Ascari; Nino Farina;
Mario Andretti; Phil Hill;
537 Error in Text
Underneath the heading Asynchronous Callback, the third sentence ends with: "defines a parameter of IAsnycResult and a void..."


should be

563 Error in Code
The code in the Main() function at the bottom of page 563 contains a undefined local variable, mevents, which should be autoEvents.
573 Error in Text
In the paragraph before the last code segment on the page:

After sleeping, the result of the calculation is written to the Result property of DoEventArgs.

The last word in the sentence should be

898 Error in Text
2nd paragraph:

To start this task, right-click your solution,...

Should be

To start this task, right-click your project,...
925 Error in Text
In final paragraph of page 925, the sentence starting with “Notice that this example uses FileStreams, ..." should be ignored.
28 933 Error in First Code Block
First code block:
//change path to math your path structure

should be:
//change path to match your path structure
933 Error in Second Code Block
Second code block:


should be:
1459 Error in Code

Should be:

1697 Error in Text
section ?foreach Statement?:

Remove the last sentence ?The For Each statement of Visual Basic doesn?t allow??

The new Visual Basic code:

For Each num as Integer In arr
See More


Additional Text for pg 319
Additional text for pg 319:

The Racer class needs to override GetHashCode and Equals for this code sample, so the racersByCar delegates return the same object instances by querying for Ferrari and McLaren.
See More

Related Titles

Back to Top