The errata list is a list of errors and their corrections that were found after the product was released.
The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.
Version |
Location |
Description |
Submitted by |
Date submitted |
Printed |
int32 i) |
L_0000: nop
L_0001: ldc.i4.3
L_0002: stloc.0
L_0003: ldloca.s i
L_0005: call instance string [mscorlib]System.Int32::ToString()
L_000a: pop
L_000b: ret
}
No box. If we add this line:
object o = i;
we get the following IL:
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 1
.locals init (
|
Anonymous |
|
Printed |
int32 i, |
|
Anonymous |
|
Printed |
Page 1
object o) |
L_0000: nop
L_0001: ldc.i4.3
L_0002: stloc.0
L_0003: ldloca.s i
L_0005: call instance string [mscorlib]System.Int32::ToString()
L_000a: pop
L_000b: ldloc.0
L_000c: box int32
L_0011: stloc.1
L_0012: ret
}
Now the int is boxed.
Interestingly, if you'd made the example call GetType instead of ToString, you'd have forced a
boxing of the int. This is because Int32 inherits GetType from System.Object.
|
Anonymous |
|
Printed |
Page 5-6
however, the values greater than 32 are not captured into any branches, which goes against |
the second last line in the third paragraph on page 83, which states "you could rewrite Example
5-6..."
|
Anonymous |
|
Printed |
Page 23
next to last paragraph |
The first sentence of the paragraph is
"As you click on each positioning indicator, a shadow appears ..."
It should be
"When you drag the mouse pointer onto a positioning indicator, a shadow appears ..."
|
Anonymous |
|
Printed |
Page 66
Table 4-2 Logical Operators |
First line in Table 4.2 Logical operators (assume x = 5 and y = 7):
Name: And
Operator: &&
Given this statement: (x == 3) && (y == 7)
This expression evaluates to: False
Logic: Both must be true.
Logic is wrong: Either or both must be false.
|
Anonymous |
|
Printed |
Page 69
The error is in the top algorithm |
In the "Learning C# 2005" book by Jesse Liberty & Brian MacDonald, on page
69, there is an error.
The error is in the top algorithm. It is missing a closing ")" after
"secondsPerMinute".
|
Anonymous |
|
Printed |
Page 82,83,84
Nested if Statements section |
The Nested If Statements section demonstrates three different ways of representing a temperature
contingent program, which is capable of displaying an appropriate message based on the value of a
temperature variable.
Of the three variations to the supposed same logic, only the latter two demonstrated, share the
same logic.
To elaborate upon this:
FIRST EXAMPLE: Example 5-6
if ( temp <= 32 )//rules out everything that is greater than 32
{
if ( temp == 32 )//Equal to
else//Less than 32
}
SECOND EXAMPLE: Example 5-7
if ( temp < 32 )//rules out anything that is greater than or equal
else if ( temp == 32 )//rules out anything that is greater than 32
else //deals with all values greater than 32
THIRD EXAMPLE: Example 5-8
if ( temp < 32 )//rules out everything that is greater than or equal to 32
else//deals with all values greater than or equal to 32
{
if ( temp == 32 )//equal to values are dealt here
else //greater than 32 values go in this block
}
Clearly, the logic flow in examples 5-7 and 5-8 follows a congruent path. In the first example
|
Anonymous |
|
Printed |
Page 86
Last line |
It is not clarified whether the output displayed towards the bottom on page 86, would correspond to
an actual invalid case selection made by the user where the default case comes into play. Otherwise
if the author is conveying the output as coming from Example 5-9 (A default statement), it is
clearly erroneous because the value of myChoice remains Party.Democrat and hence the output
should've been"
You voted Democrat.
Thank you for voting.
|
Anonymous |
|
Printed |
Page 86
last paragraph |
I believe that the example 5-9 (A default statement) does not produce the output that you have
listed. It should have produced:
You have voted Democratic.
Perhaps you would have the example you wanted for the execution of the default statement if you
added a fourth member to the enum Party (call is "Conservative") and then hard-wire the choice to
Party.Conservative instead of Party.Democrat, as you did.
|
Anonymous |
|
Printed |
Page 86
Bottom part of the page |
As another reader mentioned, there should be 4 possible options, but the 4th option was not included in the sample code. There should be something like "Progressive" as another option.
|
Anonymous |
Feb 11, 2009 |
Printed |
Page 96
First six lines |
The third and fourth line on the page should be exchanged. This will effectively take the Console.WriteLine( "For loop ended" ); out of the for loop.
|
Anonymous |
Nov 20, 2011 |
Printed |
Page 97
center of page |
"The string ends when you press A."
the STRING ends? do you mean, "execution ends" or
"program ends" or something else?
|
Anonymous |
|
Printed |
Page 121
3rd paragraph |
This paragraph references Example 7-2 when it should reference Example 7-1.
|
Anonymous |
Nov 20, 2011 |
Printed |
Page 123
near bottom |
"The Time class of Example 7-2 does not define a constructor..."
The Time class is the subject of examples 7-1 and 7-3, but not 7-2.
|
Anonymous |
|
Printed |
Page 127
middle page |
in code snippet:
public void SomeMethod(int hour)
{
this.hour=newHour;
}
The "newHour" variable should instead be "hour", representing the parameter variable passed in to the method. That's the whole point of the example: to show that the variable and an internal member have the same name, and thus the need for "this" to resolve the ambiguity.
|
Anonymous |
|
Printed |
Page 127
the implementation of SetTime methods |
this.hour = hour;
should be
this.hour = newHour;
|
Anonymous |
|
Printed |
Page 127
middle page |
in code snippet:
public void SomeMethod(int hour)
{
this.hour=newHour;
}
The "newHour" variable should instead be "hour", representing the parameter variable passed in to the method. That's the whole point of the example: to show that the variable and an internal member have the same name, and thus the need for "this" to resolve the ambiguity. Right?
|
Anonymous |
Jul 31, 2008 |
Printed |
Page 127
the SetTime method |
the method's signature requires the type of int to be given to each of those six parameters.
In fact, the whole topic headed The this Keyword, is a confusing mess, and really requires a coding example of its own.
|
Anonymous |
Apr 03, 2013 |
Printed |
Page 133
center of page, two occurrences |
"The Main() method accesses..."
"Main() then creates an instance...."
in both cases it's Run() that does it, not Main()
|
Anonymous |
|
Printed |
Page 134
On the second to last line |
method declaration should be:
public void Close()
{
not
public void Dispose()
{
|
Anonymous |
|
Printed |
Page 164
just before new topic at bottom of page |
"...I have typed in the Value > 20 as an example."
Minor points but should this be in a different font to distinguish it from the surrounding normal
text? also you say "the Value" when of course you really typed "theValue" (no space) as the
breakpoint condition.
|
Anonymous |
|
Printed |
Page 172
directions to exercise 9-2 |
"...or download it from this book's web site."
I did download the source code, and unless I goofed, there's no source code for chapter 9.
|
Anonymous |
|
Printed |
Page 184
middle of page, below code Example 10-5 |
multidimensional array variable "rectangularArray" is misprinted repeatedly as "rectangularArrayrectangularArray"
|
Anonymous |
|
Printed |
Page 184
middle of page, below code Example 10-5 |
multidimensional array variable "rectangularArray" is misprinted repeatedly as "rectangularArrayrectangularArray"
|
Anonymous |
Jul 29, 2008 |
Printed |
Page 200
bottom third |
It looks as if the base class and derived class names are mixed up in the code snippet near the bottom of p. 200: "public class MyClass : myOtherClass"
Three pages previous to the code snippet, the authors write (on p. 197): "In C#, you create a derived class by adding a colon after the name of the derived class, followed by the name of the base class. . ."
But on page 200, we find: "If you create a new class, myOtherClass, that derives from myClass, like this:
public class MyClass : MyOtherClass . . ."
So, in this (erroneous?) example the base class is on the LEFT side of the colon, not on the right side.
|
Anonymous |
|
Printed |
Page 200
bottom third |
It looks as if the base class and derived class names are mixed up in the code snippet near the bottom of p. 200: "public class MyClass : myOtherClass"
Three pages previous to the code snippet, the authors write (on p. 197): "In C#, you create a derived class by adding a colon after the name of the derived class, followed by the name of the base class. . ."
But on page 200, we find: "If you create a new class, myOtherClass, that derives from myClass, like this:
public class MyClass : MyOtherClass . . ."
So, in this (erroneous?) example the base class is on the LEFT side of the colon, not on the right side.
|
Anonymous |
Jul 31, 2008 |
Printed |
Page 200
Four paragraphs into "Controlling Access" |
An attempt was made to correct this in another errata, but the fix is still incorrect.
|
Anonymous |
Feb 11, 2009 |
Printed |
Page 213
Last paragraph |
The second example of boxing is incorrect:
int myInt = 5;
myInt.ToString( );
This will not cause a box in IL.
The following code:
static void Main( string[ ] args )
{
int i = 3;
i.ToString( );
}
Generates the following IL:
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 1
.locals init (
|
Anonymous |
|
Printed |
Page 214
near bottom |
"Example 11-5 creates an integer myIntegerVariable and implicitly boxes it..."
Isn't this example nearly identical to the example at the bottom of the previous page, where you
say "You can, of course, first cast the value type to a reference type" which you seem to imply is
a case of EXPLICITLY boxing it...you seem to be doing the same here on page 214, but you call it
"implicit"....maybe I'm confused....
|
Anonymous |
|
Printed |
Page 216
4th bullet, 4th line |
"will use the keyword overrides (rather than new)..."
For one, the keyword is "override", correct? and for two, shouldn't these be in the font reserved
for keywords, as is the keyword "new" earlier in the same bullet?
|
Anonymous |
|
Printed |
Page 224
the method shown on the bottom of that page |
On page 224 of February 2006 printing of Learning C# 2005, there is an
error in the operator overloading == to test whether two Fractions are
equal.
Specifically, the method shown on the bottom of that page would say
fractions of 1/2 and 2/4 are unequal, even though they in fact are.
public static bool operator ==(Fraction lhs, Fraction rhs)
{
if(lhs.denominator == rhs.numerator && lhs.numerator ==
rhs.numerator)
{
return true;
}
else
{
return false;
}
}
The correct method should be the following:
public static bool operator ==(Fraction lhs, Fraction rhs)
{
if (lhs.numerator * rhs.denominator == lhs.denominator *
rhs.numerator)
{
return true;
}
else
{
return false;
}
}
|
Anonymous |
Sep 08, 2008 |
Printed |
Page 241
last paragraph |
The word "defines" should be replaced by "implements."
Near the bottom of the page the following line of code
is re-printed: "public class Document : IStorable
{"
The very next line states: "This statement defines Document as a class that defines IStorable."
I believe what is meant is "This statement defines Document as
a class that implements IStorable."
|
Anonymous |
Aug 12, 2008 |
Printed |
Page 252
1/3 of the way down |
"...and then casts the Document first to be of type IStorable, then to be of type
ILoggedCompressible."
I don't see where you're casting it to be of type IStorable...either I'm misunderstanding, or
there's something amiss here.....
|
Anonymous |
|
Printed |
Page 256
middle of the page |
public class Document : Note should implement interface IStorable
public class Document : Note, IStorable
|
Anonymous |
|
Printed |
Page 257-260
There are what appear to be many typos here in the code, starting in the center of 257 |
where the if checks if the cast worked, but it checks "isStorable" for null instead of
"isStorable2", then at the bottom of 258 and continuing on into the discussion of the code which
contains 16 apparent discrepancies with the code in the continuous source code example 13-5.
|
Anonymous |
|
Printed |
Page 271
code in center of page |
Doesn't
lbt[5] = "Hello World"
need a semicolon?
|
Anonymous |
|
Printed |
Page 275
4th paragraph |
While analyzing Example 14-2, page 275, 4th paragraph
"It gets back an index and uses that index to index into myStrings:"
Should be:
"It gets back an index and uses that index to indext into strings:
Similarly (3 lines down):
"myStrings[FindString(index)] = value;"
Should be:
"strings[FindString(index)] = value;"
|
Anonymous |
|
Printed |
Page 282
Last line of the program output |
The last line of the main function is Console.WriteLine( "empList.Capacity: {0}",
empList.Capacity );
The output shows up as "empArray.Capacity: 8" intead of "empList.Capacity: 8".
|
Anonymous |
|
Printed |
Page 304
first verbatim string |
They aren't really equivalent, cuz string s2 has an extra space right before the word "My" !
|
Anonymous |
|
Printed |
Page 310
near top, typos |
"s3 goes on referring to the original string...."
"if you later write s3="Goodbye".....
I think you're referring to s1 and s2, so where you say s3 there, I think you mean s2....
|
Anonymous |
|
Printed |
Page 312-13
code and output |
It appears there's a little confusion between s3 and s5 going on. I'm referring specifically to
lines 2 and 3 of the output, and the > code that produces them: s3 is NOT 4 characters long...s5
is... you're showing the length of s5, not s3...also, since you don't mention what string you're
referring to when you say that the "5th character is r", it's implied you still mean s3, but we
already know it's only 4 characters long, so it can't have a fifth character.....you really mean
s5....
|
Anonymous |
|
Printed |
Page 319
from "Start the foreach loop..." through the end of the |
topic:
It appears your discussion refers to a variation on the code which will be developed next with the
StringBuilder class...you refer to the variable "output", as if it occurs in the previous code.
Only it doesn't.
|
Anonymous |
|
Printed |
Page 346
Qu 16.2 |
The answer to 16.2 does not appear to correspond to the question, ie there is no error of type
"CustomerCatError" and CatManager does not have the additional method call.
Exercise 16-2.
Modify Exercise 16-1 so that it does not throw an error. Create a custom error type CustomCatError
that derives from System.Exception, and create a handler for it. Add a method to CatManager that
checks the cat's age, and throws an error of type CustomCatError if the age is less than or equal
to 0, with an appropriate message.
|
Anonymous |
|
Printed |
Page 359
last 3 lines of code |
public readonly int Hour, Minute, Second;
Shouldn't those all be lacking their initial capitalization? I checked the code online, and they
are lowercase there.
|
Anonymous |
|
Printed |
Page 386
2/3 thru the page |
private void GetSubDireoctoryNodes(
clearly should be
private void GetSubDirectoryNodes(
|
Anonymous |
|
Printed |
Page 460
solution to Question 10-5 |
Employee[] myEmpArray = new Employee[3] = { moe, larry, curley
};
I think the second = produces an error, and should be absent, right?
|
Anonymous |
|