Skip to main content

Professional C#, 3rd Edition

Professional C#, 3rd Edition

Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen

ISBN: 978-0-764-57196-1

Jun 2004

1200 pages

Select type: E-Book

$32.99

Product not available for purchase

Description

What is this book about?

C# is designed to work with .NET to provide a new framework for programming on the Windows platform. This comprehensive reference prepares you to program in C#, while at the same time providing the necessary background in how the .NET architecture works.

In this all-new third edition, you’ll be introduced to the fundamentals of C# and find updated coverage of application deployment and globalization. You’ll gain a working knowledge of the language and be able to apply it in the .NET environment, build Windows forms, access databases with ADO.NET, write components for ASP.NET, take advantage of .NET support for working with COM and COM+, and much more.

Professional C#, 3rd Edition, is the complete C# resource for developers, packed with code and examples that have been updated for the latest release — the .NET Framework 1.1 and Visual Studio .NET 2003.

What does this book cover?

Here is just a few of the things you'll discover in this book:

  • How to program in the object-oriented C# language
  • Methods for manipulating XML using C#
  • Integration with COM, COM+, and Active Directory
  • How to write Windows applications and Windows services
  • Distributed applications with .NET Remoting
  • An understanding of .NET Assemblies
  • How to generate graphics with C#
  • Ways to control .NET security, and much more

Who is this book for?

This book is for experienced developers who are already familiar with C++, Visual Basic, or J++. No prior knowledge of C# is required.

Introduction.

Part I: The C# Language.

Chapter 1: .NET Architecture.

Chapter 2: C# Basics.

Chapter 3: Objects and Types.

Chapter 4: Inheritance.

Chapter 5: Operators and Casts.

Chapter 6: Delegates and Events.

Chapter 7: Memory Management and Pointers.

Chapter 8: Strings and Regular Expressions.

Chapter 9: Collections.

Chapter 10: Reflection.

Chapter 11: Errors and Exceptions.

Part II: The .NET Environment.

Chapter 12: Visual Studio .NET.

Chapter 13: Assemblies

Chapter 14: .NET Security.

Chapter 15: Threading.

Chapter 16: Distributed Applications with .NET Remoting.

Chapter 17: Localization.

Chapter 18: Deployment.

Part III: Windows Forms.

Chapter 19: Windows Forms.

Chapter 20: Graphics with GDI+.

Part IV: Data.

Chapter 21: Data Access with .NET.

Chapter 22: Viewing .NET Data.

Chapter 23: Manipulating XML.

Chapter 24: Working with Active Directory.

Part V: Web Programming.

Chapter 25: ASP.NET Pages.

Chapter 26: Web Services.

Chapter 27: User Controls and Custom Controls.

Part VI: Interop.

Chapter 28: COM Interoperability.

Chapter 29: Enterprise Services.

Part VII: Windows Base Services.

Chapter 30: File and Registry Operations.

Chapter 31: Accessing the Internet.

Chapter 32: Windows Services.

At www.wrox.com.

Appendix A: Principles of Object-Oriented Programming.

Appendix B: C# for Visual Basic 6 Developers.

Appendix C: C# for Java Developers.

Appendix D: C# for C++ Developers.

Index.

Code Downloads
Code downloads for this title are available here.
Download
Code Downloads
Code downloads for this title are available here.
Download
Code Downloads
Code downloads for this title are available here.
Code Downloads
Code downloads for this title are available here.
Download Appendix A: Principles of Object-Oriented Programming
Download
Download Appendix B: C# for Visual Basic 6 Developers
Download
Download Appendix C: C# for Java Developers
Download
Download Appendix D: C# for C++ Developers
Download
ChapterPageDetailsDatePrint Run
xxvxii Text Error
"to understand and didn't make many programming tasks easy" should be "to understand and made many programming tasks easy"
10/7/04

xxvxiiiText Error
"... , Jave is not designed to work with the .NET environment." should be "... , Java was not designed to work with the .NET environment."
10/7/04

5Text Error
"The pervious example qualifies as..."
Should be:
"The previous example qualifies as..."
6/8/05

8Text Error
"In no way with COM did component written ..." should be "In no way did COM component written ..."
10/7/04

17Text Error
"(indeed dynamic assemblies are stored in memory, not on file at all)." should be "(indeed dynamic assemblies are stored in memory, not in files at all)."
10/7/04

21Text Error
"sometimes make development difficult" should be "sometimes makes development difficult"
10/7/04

27Figure Error
In the figure, there is a missing line connecting the left "ASSEMBLY containing IL CODE" to the vertical line below "ASSEMBLY containing IL CODE" - but before the horizontal line connecting to the box ".NET base classes" -- since C# can also use these base classes. The line connecting the left "ASSEMBLY containing IL CODE" to the "CLR ORGANIZES" box should have been higher.
10/7/04

27Text Error
"Garbage collector cleans up sources" should be "Garbage collector simplifies sources" since it can automatically clean out unused items.
10/7/04

32Spelling/grammar
The line starts "Next, we declare a class ostensibly called MyFirstClass"
The class name is MyFirstCSharpClass, which is what is used in the previous page and lines following this line containing the error.
11/29/04

332nd paragraph
This refers to sentence 3: "In our case, we have have two modifiers: public and static."
Nowhere in the code blocks in the previous two pages has the 'public' access modifier been used. A person new to C# and without much of a programming background might get confused. Worse a C++ programmer would expect the access modifier for this method to be 'private' which is the default in C++ for methods and data. The access modifier should be 'public' for methods by default in Java.
11/29/04

37Error in code in text
Location: Scope clashes for fields and local variables
Description: using System; namespace Wrox.ProCSharp.Basics { class ScopeTest2 { static int j = 20; public static void Main() { int j = 30; Console.WriteLine(j); return; } } }
10/13/04

47Text Error
The syntax for the "if (condition) statement(s) else statement(s)" is wrong, it can only be "if (condition) statement | block else statement | block" since it can only be a single statement or a block of statement, which is the same as a single statement. This is clearly stated in the text below the shaded example.
10/7/04

481st code sample, Last else if block, "Newline in constant" error
The bad code is in the last else if block. There are two possible fixes:
1) The quoted string needs to be preceded by the @ symbol to allow it to span two lines, or
2) the top string needs to be properly terminated with double quotes and the string fragment remaining on the second line should be precedeeded by quotes so it can be properly concatenated to the first string with a plus (+) sign.
10/26/04

49Error in example
In the 2nd shaded example, it should be "integerA ==1" rather than "integerA =1" -- as it reinforces the earlier example in the text just above "The switch statement".
10/7/04

51Text Error
The syntax is wrong, it can only be one statement as the body of the for loop.
10/7/04

51Text Error
"The condition is the expression that is checked before each new iteration of the loop" should be "The condition is the expression that is checked before each iteration of the loop"
10/7/04

51Text Error
"and walk through the process again" should be "and repeat the process again"
10/7/04

52Text Error
"which does the same as Console.WriteLine()" should be "which is similar to Console.WriteLine()"
10/7/04

53Text Error
The syntax is wrong, it can only be a single statement in the body of the while loop.
10/7/04

55Text Error
"since C#'s switch is so strict on fall-through." should be "since C#'s switch strictly prohibits fall-through."
10/7/04

56Text Error
"TimeOfDay.Morning will return the value 0" should be "TimeOfDay.Morning is the value 0" -- as there is no evaluation! (it is simply a compile time constant)
10/7/04

60Text Error
"... C# has no equivalent to C++ header files." is false, since you can (and should) use classes to do the equivalent (via "using").
10/7/04

62Text Error
"However, when the program is invoked, we can get the CLR to pass any command line arguments to the program by including a parameter." should be "However, when the program is invoked, CLR passes any command line arguments to the program as a parameter."
10/7/04

76Text Error
Text points out that it is a convention to prefix names of members fields with an underscore but the highlighted example has no underscore.
9/24/04

76Private, Not Public
Test says "For names of all private member fields in types:"
But in the two following examples uses "public" instead of "private"
They should read "private"
4/5/05

77Typo
fifth line on this page:
The pervious example

should say:
The previous example
11/19/2006

86Text Error
"Operators are at their simplest are actions like" should be "Operators at their simplest are actions like"
10/7/04

92Text Error
"wrong overload is called." should be "wrong overload method is called."
10/7/04

97Text Error
"which constructor gets executed when." should be "which constructor is executed."
10/7/04

97Text Error
"by Microsoft as part of the framework class library," should be "by Microsoft as part of the .NET framework class library,"
10/7/04

98Text Error
There is a missing space after "Darwing.Color." and the start of the next sentence "DateTime implements ...".
10/7/04

98-99Error in code in text
The code reads: public Car(string model, uint nWheels) { this.description = description; this.nWheels = nWheels; } It should read: public Car(string description, uint nWheels) { this.description = description; this.nWheels = nWheels; } - OR - public Car(string model, uint nWheels) { this.model = model; this.nWheels = nWheels; }
10/20/04

100Text Error
"they are read-only, it cannot be assigned to outside the contructors" should be "they are read-only, the value cannot be assigned to outside the contructors"
10/7/04

101Text Error
"of bringing in the heap with all the performance implications" should be "of allocating in the heap with all the performance implications"
10/7/04

107Text Correction for page 107, 2nd paragraph
The correct code for the Money and BetterMoney classes: class Money { private decimal amount; public decimal Amount { get { return amount; } set { amount = value; } } } class BetterMoney : Money { public override string ToString() { return "$" + Amount.ToString(); } } And this is the correct code for the Main method: Money cash1 = new Money(); cash1.Amount = 40M; Console.WriteLine("cash1.ToString() returns: " + cash1.ToString()); cash1 = new BetterMoney(); cash1.Amount = 40M; Console.WriteLine("cash1.ToString() returns: " + cash1.ToString()); Running this code provides the following output to the console window: cash1.ToString() returns: Wrox.ProCSharp.OOCSharp.Money cash1.ToString() returns: $40
10/19/04

133Text Error "-" should be "--"
Note that the decrementing operator is "--" that is two minus signs and not one, in both the text, the operator shortcuts table, and the precedence table.
10/7/04

134Text Error "-" should be "--"
Note that the decrementing operator is "--" that is two minus signs and not one, in both the text, the operator shortcuts table, and the precedence table.
10/7/04

137Text Error "-" should be "--"
Note that the decrementing operator is "--" that is two minus signs and not one, in both the text, the operator shortcuts table, and the precedence table.
10/7/04

139Text Error
"if any are attepted" should be "if attepted"
10/7/04

168Text Error
"write to the library exactly" should be "write the library exactly"
10/7/04

180Text Error
"; however, there is no guarantee as to the order" should be "; as stated earlier, there is no guarantee as to the order"
10/7/04

181Text Error
"There is a convention and for readability's sake it should be followed." should be "This convention is for readability's sake it should be followed."
10/7/04

182Text Error
"write dependent code in the handlers" should be "write order dependent code in the handlers"
10/7/04

183Text Error
"and the EventArgs class has been created." should be "and the ActionCancelEventArgs class has been created."
10/7/04

184Text Error
The string should be " and not :: in the line just above the shaded example box.
10/7/04

194Text Error
"Another problem is that the implementation of a destructor delays" should be "Another problem is that the C# implementation of a destructor delays"
10/7/04

218Missing quotations in code
The line of code

char char4 = message[4];

on page 218 should be replaced with

char char4 = "message"[4];
2/9/05

468Error in Code
code block:
if (channel is HttpChannel)

should be:
if (channel is HttpServerChannel)

AND

HttpChannel httpChannel = channel as HttpChannel;

should be:
HttpServerChannel httpChannel = channel as HttpServerChannel;
10/24/06

16469-70Error in Window
page 469 + page 470 windows
Name: http

should be:
Name: http server

AND

After the 'Priority: 1' line should be another line: 'Schema: http'.
10/24/06

605Error in Text
First Paragraph:

"Most of these are self-explanatory with the exception of the two tool window borders. A tool window will not appear in the taskbar, regardless of how ShowInTaskBar is set. Also a Tool window will not show in the list of windows when the user presses Alt-Tab. The default setting is Sizeable."

should be changed to:

"Most of these are self-explanatory with the exception of the two tool window borders. A Tool window will not show in the list of windows when the user presses Alt-Tab. The default setting is Sizeable."

The second sentence is wrong and will have to be removed.
1/05/06

898Error in Code
The code at the bottom starts the function as:

protected void calendar_DayRender(obje...
Although in the downloaded source code it is:
private void calendar_DayRender(obje...

"protected" should be the right one, not "private".
7/6/05

901Missing Line
The code examples at the bottom are missing the following line:

protected System.Web.UI.WebControls.DataGrid eventDetails1;
Which should go under:
public class WebForm1 : System.Web.UI.Page

This is correct in the downloadable source code.
7/6/05

924Error in 2nd AddEvent Parameter (roomList.SelectedItem.Value)
Easiest thing to do is to change the client as follows: int queryResult = dataService.AddEvent(eventBox.Text, roomList.SelectedItem.Value.ToString(), attendees,dateString); And the web service as follows (remove two 's): String oleDbCommand = "INSERT INTO Events (Name, Room, AttendeeList, EventDate) VALUES ('" + eventName + "', " + eventRoom + ", '" + eventAttendees + "', '" + eventDate + "')"; Even better is to do it the way it's done in the new version, starting with: String oleDbCommand = "INSERT INTO Events (Name, Room, AttendeeList, EventDate) VALUES (@Name, @Room, @AttendeeList, @EventDate)"; Then add parameters to the command - this has the added bonus of preventing SQL insertion attacks.
12/7/04

28975error in text
second to last line:
dual, helpstring("ICOMDemo Interface"),

should be:
dual, helpstring("IWelcome Interface"),
10/24/06

28977Information Lacking
When building the component I received errors that there were no member function declarations for the Add and Sub member functions. Within the text it is not explained that these two member function declarations should be added to the COMDemo.h file.
10/24/06

28979Error in Second Code Block
second code block:
Console.WriteLine(obj.Greeting("Christian"));

should be:
Console.WriteLine(welcome.Greeting("Christian"));
10/24/06

28979Error in Fourth Code Block
fourth code block:
Marshal.ReleaseComObject(math);

should be:
Marshal.ReleaseComObject(obj);
10/24/06

1162Error in text
"This determination of which overload should be called..." should read: "This determination of which override should be called..."
12/6/04

AllText Correction throughout book/all pages
All of the keywords beginning with the letter i are capitalized.
This is incorrect: interface not Interface etc.
10/19/04

AllText Correction throughout book/all pages (page All)
Multiplication sign is rendered as an underscore, for example in ±1.5 x 10^-45 ("one point five times 10 to the minus 45").
10/19/04