Topic: C# and C++

Professional C# 2005 (0764575341) cover image

Professional C# 2005

Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones
ISBN: 978-0-7645-7534-1
Paperback
1416 pages
November 2005
This title is out-of-print and not currently available for purchase from this site.

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
Code Replacement / Title Content
The content for this title has been posted and may be accessed via:
http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764575341,descCd-download_code.html
04/28/2006
xxxiv Error in Code
Second line of code:

using Systm.Collections;
should read as:
using System.Collections;
01/03/06
xxxix Error in Code
Page "xxxix", the section on Nullable types:

Code reads:
System.Nullable x = new System.Nullable<int>;

The error reads:
"A new expression requires () or [] after type"

code should read:
System.Nullable x = new System.Nullable();
07/31/06
xl Error in Text
First code box

“Minnesota Vikiings”
should be:
“Minnesota Vikings”
3/7/06
xli Error in Text
2nd paragraph under “Where C# Fits In”

“simple to understand and didn’t make many programming tasks easy”
should be:
“simple to understand and made many programming tasks easy”
3/7/06
76 Error in Code
Code snippet of the first bullet at the bottom of the page:

public int subscriberID;
should read as:
public int subscriberId;

Note the lowercase 'D' of the 'Id'. Also the code snippet of the second bullet on the same page:

public int subscriberID;
should read as:
public int _subscriberId;
1/03/06
76 Error in Reference
towards the bottom of the page:
For names of all private member fields in types: public in subscriberId

should say:
For names of all private member fields in types: private in subscriberId
10/16/06
97 Text Error
First sentence in last paragraph

It is written,
“… is imaginatively called StaticConstructor”

However, in the following code box, there is no indication that the example is called “StaticConstructor”.

The namespace though ends with .StaticConstructorSample.
3/13/06
98-99 Error in Text
All instances of
string model
should be
string description
1/20/06
100 Error in Text
Last sentence:
“they cannot be assigned to outside the constructors”

should be:
“they cannot be assigned outside the constructors”
3/13/06
102 Error in TExt
Code should read:

public double Diagonal (not public int Diagonal)
01/03/06
107 Error in Text
Method table

Public and Protected for GetType() and MemberwiseClone
should be
public and protected (p in lowercase)
01/03/06
107 Error in Text
second entry in the table"

"intGetHashTable()"

should be

"intGetHashCode()"
1/17/06
107 Error in Text
"int GetHashTable()" at the top of the page should read "int GetHashCode()"
11/17/06
109 Text Error
Last paragraph

The last paragraph refers to a BetterMoney object in the code above the paragraph; however, there is nothing in that code referring to BetterMoney.
3/13/06
124 Error in Text
Text reads:

Note that type definitions can be public or private, depending on whether you want the type to be visible outside its containing assembly. public class MyClass
{
// etc.
You cannot define types as protected, private, or protected internal, becauseas these visibility levels would be meaningless for a type contained in a namespace. Hence these visibilities can only be applied to members. However, you can define nested types (that is, types contained within other types) with these visibilities, becausesince in this case the type also has the status of a member. Hence the following code is correct

Should read:

Note the type definitions can be internal or public, depending on whether you want the type to be visible outside its containing assembly. public class MyClass
{
// etc.
You cannot define types as protected, private , or protected internal, because as these visibility levels would be meaningless for a type contained in a name space. Hence these visibilities can only be applied to members. However, you can define nested types (that is, types contained within other types) with these visibilities, because since in this case the type also has the status of a member. Hence the following code is correct"
04/27/2006
143 Error in Code
int approximatePrice = (int)(price + 0.5);

should be:
int approximatePrice = (int)(price >= 0 ? price + 0.5 : price - 0.5);
05/10/07
150 Choice of Wording
First paragraph of section of “Operator Overloading Example: The Vector Struct”

A Vector does not “tell you how far something is moving” it “tells you where something is”

Replace use of the words movement/moving with displacement/(is) displaced
3/15/06
161 Error in Code
Code in Main

The testing number should be -50.5 (or -50.35, not -100.00)
The result shown in the shell window is $4294967246.00
1/03/06
163 Error in Text
"...(assuming you want the casts to be explicit, which is usually the case when defining casts between user-defined casts): "

should be:

"...(assuming you want the casts to be explicit, which is usually the case when defining casts between user-defined classes): "
07/25/2007
166 Error in code
double amountD = (double)(float)balance;
With the explicit cast and the data set to 50.35 (not 10.50), the result is 50.3499984741211.
Without the explict cast, I got 50.35. That means:

double amountD = (double)(float)balance;
and
double amountD = balance;
don't do exactly the same thing
01/03/06
187 Error in Code
At the bottom, it has code for doing an anonymous instantiation of an EventHandler object, like this:

btnOne.Click += new EventHandler(lblInfo.Text = "Button One was pressed";);

This code won't compile. Possibly it has to be something like this, which does compile:

btnOne.Click += new EventHandler(delegate(object o, EventArgs e) {lblInfo.Text = "Button One was pressed";});
04/28/2006
208 Error in Figure
Figure 7-5:
pY=012F8C4

Should be:
pY=0x12F8C4
04/19/07
209 Error in Code
int* pointerToInt;
void* pointerToVoid;
pointerToVoid = (void*)pointerToInt;

should be:

int x = 32;
int* pointerToInt = &x;
void* pointerToVoid;
pointerToVoid = (void*)pointerToInt;
05/16/07
238 Typos
were
should be:
where

AND

regular collections
should be:
regular expressions

AND

to only contain
should be:
to contain only
05/16/07
240 Error in Expression
The regular expression [0-9]+ only matches /positive/ integers. If it is to match /all/ integers, as claimed, then it must be changed to -?[0-9]+ so that it also matches negative integers. If not, then the claim needs to be weakened from "integer" to "natural number".
05/23/07
240 Errors in Reference
The section "Displaying Results":
second paragraph: refers to "input text quoted earlier" that wasn't quoted in the book, but appears in the downloadable code for Chapter 8 (RegularExpressionsPlayaround.cs).

AND

bottom line: refers to a property "Value", but the code uses "ToString()" instead.
05/23/07
241 Error in Code
The "Find2()" code shown on p.241 differs in both "text" and "pattern" from the "Find2()" method in the downloadable code.

AND

The "Find1()" method was not, as claimed, shown previously in the book, but it does appear in the downloadable code.

AND

The output shown in text differs from that obtained by running the downloadable code.
05/23/07
248 Error in Text
fist line in the topic "Adding collection support..."

"The Vector struct started in Chapter 3..."

should be

"The Vector struct started in Chapter 5..."
1/17/06
259, 261 Error in Code
EmployeeData theEmployee = employees[id];

should be:
EmployeeData theEmployee = (EmployeeData)employees[id];
05/21/07
9 263 Error in Concept and Code
In the first sentence, last paragraph:

“The smaller the maximum load, the more efficiently your hashtable works…”
Usually the efficiency of a Key depends on how it loads in relation to how the algorithm expects. You can plan a balanced or skewed loading which will have and effect on what the Load should be. AND Hashtable employees = new Hashtable(50, 0.5); should be: Hashtable employees = new Hashtable(53, 0.5F);"
03/23/2006
264 Outdated information
Please disregard statement:
"or you might try to retrieve an entry and get the wrong entry returned"
05/21/07
288 Error in Figure 10-3
Figure 10-3:

List<LinkedListNode<Documents>
Should read:
List<LinkedListNode<Document>>

AND

LinkedList<Documents>
should read:
LinkedList<Document>
1/12/06
10 294 Unexplained Class Definition
In the last sentence of the second paragraph of Constraints:
ProcessDocuments appears without explanation. Up to this point, it is not insinuated that a Generic Class could have two or more Types in its definition.
03/23/2006
296 Code Error
T doc =
documentManager.GetDocument();

should read:

TDocument doc =
documentManager.GetDocument();
1/12/06
10 303 Error in Text/Code
Last sentence, second paragraph of ArraySegment:
Last element:
6
should be: 5


AND

In the Code Box:
Assuming "count" is the number of elements in the Segment, the "for" Statement should be one of the following:

(a) for (int i = segment.Offset; i < segment.Offset + segment.Count + 1; i++)
(b) for (int i = segment.Offset; i <= segment.Offset + segment.Count; i++)
03/23/2006
321-322 Error in Text/Code
1. In Main():
the "return;" after "AddToMessage(\"This assembly does not support WhatsNew attributes\");" should be removed, as this would cause the program to exit immediately, without displaying this error-message.

SO

2. To accommodate the above change, the code on p.322 following the else-statement needs to be in curly brackets as follows:
else
{
AddToMessage("Defined Types:");

Type[] types = theAssembly.GetTypes();
foreach (Type definedType in types)
DisplayTypeInfo(theAssembly, definedType);
}
05/25/07
321 Error in Code
Rather than hard-wiring backDateTo into the code, it should be input by the user:
for example, by expanding the code from 2.(previous errata) as follows:
else
{
while (true)
{
Console.Write("Enter date: ");
try
{
backDateTo = DateTime.Parse(Console.ReadLine());
break;
}
catch (FormatException fe)
{
Console.WriteLine("Input not recognised as a valid date - please try again.");
}
}
AddToMessage("Defined Types:");

Type[] types = theAssembly.GetTypes();
foreach (Type definedType in types)
DisplayTypeInfo(theAssembly, definedType);
}
05/25/07
322 Error in Method
AddToMessage(nextMethod.ReturnType + " " + nextMethod.Name + "()");
should be:
AddToMessage(nextMethod.Name);

...because it displays all methods as though they took no parameters, which is not the case! So if we're not going to bother displaying the method-signatures properly, it would be better to display just the method-names to avoid implying that the signatures currently displayed are correct and complete.
05/25/07
328 Missing Word
very similar using exceptions

should be:
very similar to using exceptions
05/22/07
329 Typos
box that reads: 10Exception

should be: I0Exception
(the "1" should be changed to an "I")

AND

Figure 12-1:
ArgumentExeption

should be:
ArgumentException
1/17/06, 5/22/07
335 Error in Text
Bottom line:
and ending with the most general options.

should be:
and the lowermost catch block should be the most general option.
(where "catch" is in the fixed-width font)
05/22/07
343 Errors in Chapter Reference
The "principles laid down for the disposing of objects" are in Chapter 7 -not Chapter 4 as stated in the first paragraph of "Throwing the user-defined exceptions".

AND

File-handling is discussed in depth in Chapter 34 - not Chapter 35 as stated here.
05/22/07
356 Missing Code
after the end of the Main() method (before the last curly bracket):
this section should be added to the code:

/*
More…
*/
05/29/07
401 Error in Text
first bulleted paragraph under Extra source code debugging commands:
unless it is explicitly #undefined in the source code.

should read:
unless it is explicity undefined using the #undefine compiler directive in the source code.
(because there is no #undefined directive.)
05/29/07
407 Error in Figure Reference
Under Figure 14-27, second sentence:
"For example, in Figure 14-24..."

should read:
"For example, in Figure 14-27..."
05/29/07
415 Incorrect Figure
Figure 15-2 is wrong. The output of the console should say:
Main in domain AssemblyA.exe called
1/20/06
447 Error in Text
2nd line from bottom reads:
Pay attention to the use of uppercase P!

2nd line from bottom should read:
Pay attention to the use of uppercase T!
11/03/06
459 Error in Text
In the paragraph between the two grey boxes:
<supportedVersion>

should be:
<supportedRuntime>
05/25/07
472 Error in Text
final paragraph before 3 bullets:
The text reads:
Another set of permissions is asigned by the CLR on the basis of the identity of the code, which cannot be granted.

should be:
Another set of permissions is asigned by the CLR on the basis of the identity of the code.

The phrase "which cannot be granted" should be deleted.
10/10/06
490 Error in Text
"13. In the Properties window, located the...."

"located" should be "locate"
12/22/05
16 Chapter 16 Password Request
The files provided in WROX software packaging are supposed to be used per instructions associated to them from the book. If you are required to open this file separately per instructions in the book, the password will be provided. If not then it may be just an accessory to the rest of the packaging for chapter 16. For further inquiries, you may visit the WROX forum for this title at the following and submit your request http://p2p.wrox.com/forum.asp?FORUM_ID=221
05/10/2006
17 528 Error in Text
Last word of second line reads:
Image.ToFile

Should Be:
Image.FromFile
06/26/2006
541 Error in Text
in the Box on the page for the translations under the name column, the names should have an underscore added ie: Good Morning should be Good_Morning - similarly this should be done for Good Afternoon and Good Evening.
1/17/06
575 Missing reference
last sentence:
"MDAC" should be described as 'Microsoft Data Access Components' with reference to its context (SQL Server databases).
11/28/06
584 Error in Code
At the bottom of the page, reads:
ConfigurationSettings.ConnectionStrings[name];
should be:
ConfigurationManager.ConnectionStrings[name];
12/09/05
596 Error in Text
The first sentence under "Record insertion":
The Region table only consists of..."

should read:
"The Region table consists only of..."
05/29/07
600 Typos (2)
paragraph before "Managing Data ...":
"... which unitl this was tested under the release version of .NET it was."

should be:
"... which until this was tested under the release version of .NET was."
05/29/07
601 Table column identifier mistake
The title above the Data Column in figure 19-4 DataRow
should be:
DataColumn.
2/21/06
611 Error in Text
"There are six different constructors for the ForeignKeyConstraing class - I would suggest using those that permit you to name the constraint".
2/21/06
630 Error in Text
("Conventions for constraints": third point)

"length of the constraint"

should be:

"length of the constraint-name"
02/06/2008
635 Error in Text
Table: SqlContext:

"WindowsIdentitiy"

should be:

"WindowsIdentity"
02/08/2008
635 Error in Text
Table: SqlPipe:

"to either send a SqlDataReader, SqlDataRecord, and string"

should be:

"to send either an SqlDataReader, an SqlDataRecord or a string"
02/08/2008
650 Error in Text
When opening the reader, there is a space where it shouldn't be: (CommandBehavior.Close Connection);
2/13/06
651 Error in Text
"Events table"

should be:

"Exams table"
02/19/2008
651 Error in Code
('70-315,
should be:
Exam values('70-315'...

ALSO

(70-316,
should be:
('70-316'

ALSO

<Exam
should be:
'<Exam
^this appears twice on 651
02/19/2008
652 Error in Code
('70-320,
should be:
('70-320',

ALSO

<Exam
should be:
'<Exam
02/19/2008
655 Error in Code
SET Info.modify('delete /Exam[1]/Course[5])

should be:

SET Info.modify('delete /Exam[1]/Course[5]')

ALSO

SET Info.modify('replace value of
/Exam/Course[text() = 2310]/text()[1] with
2644'
FROM Events

should be:

SET Info.modify('replace value of
(/Exam/Course[text() = 2310]/text())[1] with
2644')
FROM Exams

ALSO

(second paragraph under "XML Indexes") --

"idx_events on the Event column"

should be:

"idx_exams on the Info column"
02/19/2008
655 Error in Code
SET Info.modify('delete /Exam[1]/Course[5])

should be:

SET Info.modify('delete /Exam[1]/Course[5]')
02/19/2008
656 Error in Code
WHERE
Info.exists('//Certification[@Name="MCAD"]') = 1

should be:

WHERE
Info.exist('//Certification[@Name="MCAD"]') = 1
02/19/2008
21 667 Error in Text
In manipulating XML

The ReadValueAs methods should all be changed to ReadElementContentAs. There are the 5 instances in this section and there is one more reference in the section on XPathNavigator.
05/09/2006
673 Error in Text
math

should be:

match
02/20/2008
673 - 677 Error in Code
The code-boxes on pp. 673 and 675-677 are inconsistent as to whether the XmlDocument variable is called "doc" or "_doc": it's called "doc" in most places, but my recommendation is to stick to the convention of using an underscore for a private member-field.

_doc should be changed to doc
02/20/2008
678 Error in Code
(paragraph under code-box)--
xml
should be:
XML

ALSO

("Using XPathNavigators)--
(a) "XPathNavigaor"
should be:
"XPathNavigator"

(b) "xml"
should be
"XML"
02/20/2008
679 Error in Text
("XPathDocument")--

(a) "other then" -> "other than"
(b) "xml" -> "XML" (twice)
(c) "Stream based" -> "Stream-based"
(d) "ti" -> "to"
(e) "the use" -> "then use"
02/20/2008
680 Error in Text
(paragraph above "XPathNodeIterator"

(a) "form the nods" -> "from the nodes"

(b) "XmReader" -> "XmlReader"
02/20/2008
680/681 Errors in List
(list on pp.680/681)--

(b) "Clone" should be moved from the start of the list to after "CurrentPosition" and before "MoveNext", and changed to "Clone()", because it is a method rather than a property.

(c) "CurrentPosition()" SHOULD BE "CurrentPosition", because it is a property rather than a method.
02/20/2008
681 Error in Text
Change the file booksxpath.xml to
"XPathDocument doc = new
XPathDocument("books.xml");"
1/20/06
681 Style Clarification
(a) "the XPathNavigators select methods"

XPathNavigator (without s) should be code style, and the s should be normal text
02/20/2008
686 Error in Text
In text

"BookUtils"
Should be:
"BookItils"
2/13/06
758 Error in Text
In hierarchy:

System.Windows.Form.UpDown
Should be:
System.Windows.Form.UpdDown

and

DataGridView
Should be:
DateGridView
2/13/06
23 766 Error in Text
In the 3rd paragraph "SelectValue" should read "SelectedValue"

AND

In the 3rd code snippet "SelectValue" should read "SelectedValue"
05/01/2006
774 Error in Text
Paragraph 2:

constructor
Should be:
constrictor
2/13/06
777 Error in Text
The first two items in the list

should be:

The last two items in the list
06/25/2007
783 Error in Text
second paragraph, line 7:

"For this example, you need to phone number."

should be:

"For this example, you need the phone number."
08/14/2007
23 786 EnableVisualSyles method availability
First paragraph. last sentence:

"Also, EnableVisualStyles is available only in .NET framework 1.1."

This is incorrect, EnableVisualStyles method is available in .NET 2.0 as well as .NET 1.1, but not .NET 1.0.

From MSDN documentation:
"Application.EnableVisualStyles Method
...
Version Information
.NET Framework
Supported in: 2.0, 1.1"
2/28/06
809 Error in Text
DataGridView
Should be:
DataGrid control
08/25/06
835 Error in Code
The lower code-box on p.835 does not (textually) match the code on p.833, which makes it difficult to find in the source-code I've typed in. Specifically, the first three lines should be replaced with...

ContextMenuAttribute[] ctx = ContextMenuAttribute[])
meth.GetCustomAttributes(typeof(ContextMenuAttribute), true);

...if the code on p.833 is to be the definitive version.
02/19/2008
835 Error in Code
The lower code-box on p.835 does not (textually) match the code on p.833, which makes it difficult to find in the source-code I've typed in. Specifically, the first three lines should be replaced with...

ContextMenuAttribute[] ctx = ContextMenuAttribute[])
meth.GetCustomAttributes(typeof(ContextMenuAttribute), true);

...if the code on p.833 is to be the definitive version.
02/19/2008
837 Error in Code
The second code-box on p.837 is missing the line...

public bool Default;

...which should be inserted under the existing line:

public readonly string Caption;
02/19/2008
839 Clarification
'DataSet and DataMember are Customers.'

should be:

DataSource in this instance refers to a DataSet, and DataMember is set to "Customers".
02/19/2008
840 Error in Text
'includes large number'

should be:

'includes a large number'
02/19/2008
31 1111 Error in Text
Last paragraph, before code, reads:

"This class just has a one property...";
Should read:
"This class just has one property..."
6/26/06
1240 Error in Text
"...it can make accomplishing some specific Internet access tasks easier for you to accomplish."

should be:

"...it can make accomplishing some specific Internet access tasks easier for you."
07/11/2007
16 Obsolete Code
The application for chapter 16 of Professional C# 2005 called SimpleExample has a line of obsolete code in the download that will cause it to not compile. This code is in the file called Program.cs and reads as "Application.EnableRTLMirroring();". Leaving this line of code in the application will result in a compile error.

By taking this line out of the code, the application will run without any issues as it will load the data from animal.txt as shown in the book.
12/13/2007