Errata

C# 4.0 in a Nutshell

Errata for C# 4.0 in a Nutshell

Submit your own errata for this product.

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.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 4
Figure 1.1

"macorlib.dll" should be "mscorlib.dll"

Anonymous  Sep 09, 2010 
Printed Page 4
Figure 1-1

The heading of the dotted line circle reads macorlib.dll.
It should be mscorlib.dll.

Morten Thomas  Apr 26, 2011 
Printed Page 10
in the Tip

Change "We explain assemblies in detail in Chapter 16." to "We explain assemblies in detail in Chapter 17."

Howard Weisberg  Dec 19, 2010 
Printed Page 12
middle of page

Change ?The semicolon is used to terminate a statement. ... The Braces are used to group multiple statements ... The period denotes ... The parentheses are used ... (the equal sign ... ? to ?A semicolon is used to terminate a statement. ... Braces are used to group multiple statements ... A period denotes ... Parentheses are used ... (an equal sign ...?

Howard Weisberg  Dec 19, 2010 
Printed Page 15
"Instance and static members" section

Although this is very early in the book and in the development of C# 4.0 concepts, perhaps a footnote should be added that refers to pg. 947, first paragraph, 2nd and 3rd sentences, which say about multiple application domains :

"... each domain has separate memory, and objects in one domain cannot interfere with those in another. Furthermore, static members of the same class have independent values in each domain."

JimboT  Feb 24, 2011 
Printed Page 19
Denmark

In figure 2-4 the value of Y is shown to be 7 in the object pointed to by p1 and p2. This appears to be wrong, since Y has not changed since being initialized to 0.

Jacob Berlin Rasmussen  Sep 18, 2012 
PDF Page 25
3rd line of code after first paragraph

In the comment, is says DivisionByZeroException. It should be DivideByZeroException.

johnsterling  Jun 10, 2011 
PDF Page 32
String concatenation

The text implies that conversion to string will only be done for the righthand operand for the + operator. However, according to MSDN's C# reference:

When one or both operands are of type string, + concatenates the string representations of the operands.

johnsterling  Jun 07, 2011 
Printed Page 56
First sentence in the section on Miscellaneous Statements

The text refers the reader to Chapter 19 for a discussion of the lock statement and the Monitor class but that discussion is in Chapter 21.

Hanna Ruotsalainen  Nov 02, 2010 
Printed Page 57
using Directive section

There should be something in this section about what the compiler does if you have multiple using statements referencing different namespaces that just happen to have an identically named type that you want to use without any qualification. In this case the compiler issues an error indicating that the use of the type name is ambiguous. This is an important safety factor which your readers should be aware of. Maybe an example would help:

Suppose you have this situation:
namespace X.Y (which has a type A in it)
namespace M.N (which also has a type A in it)

In your code you have this:
using X.Y;
using M.N;
....
A a; // the compiler will issue an error about this being ambiguous
....

What do you think?

I know this info was very reassuring to me that I wouldn't be accidentally using the wrong type if it just happened to be in multiple namespaces I was using in my code. I was happy to find out that the compiler told me about the ambiguous type name.


Thanks!
John

John Pinto  Sep 02, 2010 
Printed Page 57
Namespaces section

In your examples of nested namespaces, while technically correct, they seem to give the impression that namespaces such as, e.g., System.Collections and System.Collections.Generic are programmatically related, when they are not. The paw print note on p. 59 hints at this but isn't explicit as it should be. For example, this of course is not valid C# code:

using System.Collections;
Generic.List<string> mylist;

but your examples might lead one to think it is. Better to be explicit about the .NET namespace hierarchies.

Anonymous  Jun 21, 2011 
Printed Page 60
First example in "Alias Types and Namespaces"

The example code demonstrates aliasing a namespace, but the expression references a class, not a namespace and will not compile.

Stan Morris  Mar 20, 2010 
Printed Page 71
middle of page

Replace ?The syntax for using indexers is like that for using arrays when the index is an integer type.? with ?The syntax for using indexers is like that for using arrays except that the index parameter(s) can be any type(s).?

Howard Weisberg  Dec 19, 2010 
Printed Page 78
last paragraph in Upcasting section

"To get to its SharedOwned field [...]" should be replaced with: "To get to its SharesOwned field [...]"

Piotr K.  Feb 15, 2011 
Printed Page 88
listing

Replace ?Public extern Type GetType()? with ?Public Type GetType()?

Howard Weisberg  Dec 19, 2010 
Printed Page 88
2nd caption

Under caption "Object Member Listing" class Object's member GetType() is listed with the extern modifier, which is different from the MSDN documentation: http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx

Anonymous  Sep 04, 2011 
Printed Page 90
1/3 of the way down

Replace ?? the default accessibility members of a class or struct? with ?? the default accessibility of members of a class or struct?

Howard Weisberg  Dec 19, 2010 
Printed Page 93
subsection ?Explicit Interface Implementation?

Add a reference to this subsection to the index.

Howard Weisberg  Dec 19, 2010 
Printed Page 103
first hyphenated line

"nee- / ded" to "need- / ed"

Anonymous  Jan 11, 2011 
Printed Page 107
3rd paragraph

Text says "where the type parameter T is of the type parameter U:"
Then a few lines later in the code it says
Stack<U> FilteredStack<U>() where U : T{...}

Doesn't that mean that parameter U is of type T?

Tod Gentille  Aug 05, 2011 
Printed Page 120
Section "The Func and Action Delegates"

Both Func<> and Action<> accept only up to T4, not up to T16.

If the latest is true in C# 4.0, there should be a note specifying that versions from T5 and upwards are new to C# 4.0, as in other places in the book.

Gorpik  Mar 11, 2010 
Printed Page 123
Last sentence of "Return type compatibility" section

This sentence should say :

"... get back an object, but an STRING subclass will also do:",

instead of :

"... get back an object, but an OBJECT subclass will also do:",

JimboT  Feb 20, 2011 
Printed Page 123
First sentance

"...,you may get back a type that is more specific..." should be "LESS specific". Similar to other unconfirmed error on same page.

Richard Fayko  Nov 14, 2011 
Printed Page 137
First sentence of the tip before "The finally Block"

This sentence says :

"In languages other than C#, it is possible (...) to throw an object that does not derive from Exception."

It should say :
"In languages other than C# and VB .NET, it is possible (...) "

In Visual Studio 2010's Help for the RuntimeWrappedException class, it says that VB .NET also requires every thrown exception be derived from the Exception class.

The correct answer could be resolved by trying, in VB .NET, to throw an object that does not derive from the Exception class.

JimboT  Feb 20, 2011 
Printed Page 138
Omission from "The using statement"

Why is there no mention of the possibility (described in section 8.13 of the C# Language Specification, Version 4.0) of declaring several objects with a single declaration? E.g.:

using (StreamReader r1 = ..., r2 = ...)

Perhaps because the C# language lawyers didn't really want it but felt that they had to re-use an existing grammar production? After all, this is not allowed:

using (StreamReader source = ...; StreamWriter sink = ...)

Anonymous  Feb 10, 2011 
Printed Page 142
Accumulator class

The presented Accumulator pattern is much too complicated. It has two disadvantages:
1. It is slow because the try-finally block consumes a lot of processor cycles (as stated on page 136)
2. It will fire a lot of undesired 'OnPropertyChanges' on 'Total' if extended with the 'INotifyPropertyChanged' interface.

An easier and more effective version:

public class Accumulator
{
public int Total;

public void Add(params int[] ints)
{
int currentTotal = Total;
foreach (int i in ints)
{
checked
{
currentTotal += i;
}
}
Total = currentTotal;
}
}

Andres Rohr  Apr 23, 2011 
Printed Page 144
Last sentence before the tip

This sentence states :

"If the enumerator implements IDisposable, the (bold font) foreach statement also acts as a (bold font) using statement, ..."

It should say :

"If the enumerator implements IDisposable, the (bold font) using statement also acts as a (bold font) finally statement, ..."

JimboT  Feb 20, 2011 
Printed Page 153
Second sentence of second bullet item

This sentence says :

"The same is true for our earlier examples representing an unknown account balance and an unknown temperature."

The earlier example of an unknown account balance is on pg. 152. What page is the unknown temperature example on? Was an unknown quantity other than temperature meant?

JimboT  Feb 20, 2011 
Printed Page 156
2nd paragraph in "Miscellaneous Statements"

Should be:

... (see "try Statements and Exceptions" on page 138 in Chapter 4 or ...

Anonymous  Jan 11, 2011 
Printed Page 162
in Tip

Change "third" to "fourth". 1) Static, 2) Dynamic, 3) Custom, 4) Language, 5!) Interop. Wait change it to "fifth" or "another"!

* "Among the our main types of binding are: ..." -- Monty Python, Spanish Inquisition sketch.

Anonymous  Jan 11, 2011 
Printed Page 164
Runtime Representation of Dynamic - example following 1st paragraph

typeof(dynamic) gives the compiler error: The typeof operator cannot be used on the dynamic type.

Alan Fox  Jun 28, 2010 
Printed Page 169
near the bottom

Replace ?We describe how to write your own attributes in Chapter 17.? With ?We describe how to write your own attributes in Chapter 18.?

Howard Weisberg  Dec 19, 2010 
Printed Page 191
last paragraph

Replace ?The types for communicating with WCF are in, and are below, the System.ServiceModel namespace.? with ?The types for communicating with WCF are in, and below, the System.ServiceModel namespace.?

Howard Weisberg  Dec 19, 2010 
Printed Page 192
5th hyphenated line

Change "intero- / perbility" to "inter- / operability"

Anonymous  Jan 11, 2011 
PDF Page 200
near top

because the following returns 1
String.Compare("Atom","atom",StringComparison.InvariantCulture); //
so correct sequence is
"atom" , "Atom" , "Zamia"
and in a few lines below that also there is a mistake for InvariantCulture,
"AaBbCcDe.." must be corrected to "aAbBcCdD.."

iman abidi  Jul 13, 2012 
Printed Page 201
near the top of page

Replace ?The result of the final comparison ?? with ?The result of the third example ??

Howard Weisberg  Dec 19, 2010 
Printed Page 212
first block of code

To get a result that will be correct for all readers, change the code
Console.WriteLine(dt.Add(ts);
Console.WriteLine(dt + ts);
to
Console.WriteLine(
dt.Add(ts).ToString(CultureInfo.InvariantCulture));
Console.WriteLine(
(dt + ts).ToString(CultureInfo.InvariantCulture));
Also change ?3/02/2000? to ?2/03/2000? in two places.

Howard Weisberg  Dec 19, 2010 
Printed Page 238
6th paragraph in section "BigInteger"

"You can implicitly cast a BigInteger to a standard numeric type and explicitly cast in the other direction." This sentence is only valid for floating-point standard numeric types. Cast from integral types are already covered at the beginning of the section.

Gorpik  Mar 17, 2010 
Printed Page 238
8th paragraph in section "BigInteger"

"BigInteger overloads all the arithmetic operators, as well as [...] modulus(%) [...]". In fact, modulus is an arithmetic operator.

Gorpik  Mar 17, 2010 
Printed Page 250
class Test<T>

The line
public bool IsEqual(T a, T b)
should read
public bool Equals(T a, T b)

The interface 'IEquatable' requires 'Equals' not 'IsEqual'.

Greetings
A. Rohr

Andres Rohr  Jul 03, 2011 
PDF Page 263
Top of the page, just before the heading "Enumerating Enum Values"

According to the documentation of Enum.Parse, it throws an "ArgumentException", not a "FormatException", if the member is not found.

Voltage Spike  Feb 22, 2012 
Printed Page 269
First code example

Brittle code: a client application will crash if it calls MoveNext() one time after reaching the end of the collection, and then proceeds to get the Current property.

Example with an empty collection:
collection.data.Length == 0
currentIndex == -1;

- First call to MoveNext(): currentIndex == 0
- Second call to MoveNext(): currentIndex == 1

Get on the Current property: IndexOutOfRangeException, probably not caught by the caller.

The client is asking for it, ignoring MoveNext()'s return value, but making the code more robust is an easy fix:

if(currentIndex > collection.data.Length) return false
becomes
if(currentIndex == collection.data.Length) return false
or
if(currentIndex >= collection.data.Length) return false

AlvinMinring  Apr 05, 2011 
PDF Page 275

object[] a1 = { "string", 123, true };
object[] a2 = { "string", 123, true };
Console.WriteLine (a1 == a2); // False
Console.WriteLine (a1.Equals (a2)); // False
Console.WriteLine (a1.Equals (a2,
StructuralComparisons.StructuralEqualityComparer)); // True

This code does not compile

Terje Solem  Mar 01, 2012 
Printed Page 277
2nd paragraph after code sample and hint

Array.CreateInstance appears as two separate words (Array.CreateIn stance)

Gorpik  Mar 23, 2010 
Printed Page 284
code sample at the top

Close up the white space between ?}? and ?Public delegate TOutput Converter ? .?

Howard Weisberg  Dec 19, 2010 
Printed Page 293
3rd paragraph

TryGetValue appears as two different words (TryGet Value).

It looks like there is some typographical problem throughout the book; I sent similar errata for pg. 277, and I suspect there may be more. The typeface used for function names does not display a hyphen if one of these names is spread upon two different lines; this might lead to confusion.

Gorpik  Mar 26, 2010 
Printed Page 304
paragraph before title : Iequality and....

"which allows the option of structural comparisons on Tuples and arrays (and not classes)

Royi Namir  Mar 17, 2012 
Printed Page 309
Last code listing

This example should be case-insensitive in order to work like the SurnameComparer in the previous section. Besides, as it is, it gives awkward results with names starting in Mc.

Gorpik  Mar 29, 2010 
Printed Page 333
diagram at top, Figure 8-8

Diagram is for the following statement

names.Where (n=>n.Length == names.OrderBy(n2=>n2.Length)
.Select(n2=>n2.Length).First());

based on my understanding of the text, the subquery is:

names.OrderBy(n2=>n2.Length)
.Select(n2=>n2.Length).First()

However, Figure 8-8 shows the .First() call as not being part of the subquery -- but figure 8-7 does show .First() as being part of the subquery

James Schumacher  Jul 11, 2012 
Printed Page 344
2nd code listing and text afterwards

In the code example and its SQL equivalent, Pair() is called after OrderBy(); but the explanation after the code and the diagram in figure 8-10 call Pair() before OrderBy().

Gorpik  Apr 05, 2010 
Printed Page 344
Code and result display before 3rd paragraph

Two problems:

Problem 1:
Assuming the code is changed from the previous example (class Test on page 340) then 'class Test' must become 'static class Test' or the extension method 'Pair' will not compile. Alternatively, method 'Pair' can exist inside its own static class.


Problem 2:

For the designated output:
Pair 0=HARRY, MARY
Pair 1=TOM, DICK
The OrderBy clause must follow the Pair clause.


For the published code, with the OrderBy clause
before the Pair clause, the following is the the
correct output:

Pair 0=DICK, HARRY
Pair 1=JAY, MARY

Steven Rogers  Jun 29, 2010 
PDF Page 361
IEnumerable query / 5th paragraph

.OrderBy (n => n) should be after .Pair(), not before,
as noted in the LINQPad 4 example.

Bobby  Aug 03, 2010 
Printed Page 377
Code example in section "Select subqueries and object hierarchies"

In the last line of the code example, better use " - Len: " instead of just "Len: " to avoid messing the file names.

Gorpik  Apr 05, 2010 
Printed Page 386
Code listings

The C# class Purchase has a field called Date, but this does not appear in the SQL table definition below.

Gorpik  Apr 05, 2010 
Printed Page 478
table

Page incorrectly discribes the actions of StreamReader/
StreamWriter, these objects do not call flush automatically during the Dispose method .

StreamReader,
StreamWriter

under Disposal function:

Reads:
Flushes the reader/writer and closes the underlying stream

Should read:
Closes the underlying stream.

Anonymous  Oct 02, 2012 
Printed Page 479
478 (Opt-in disposal), 479

Page 478, code listing in "Opt-in Disposal":
Code defines a class called "HouseManager" but the following paragraph in pg 479 2nd sentence:
"This, however, relies on the consumer knowing what's inside Demo's Dispose method."

There is no Demo class.

Same for page 479, 2nd code listing:
Constructor called Demo in a class called HouseManager.

kchow8  Jul 21, 2011 
Printed Page 490
Last sentence of tip

This sentence states :

"In effect, the server GC is tuned for throughput rather than latency."

The tradeoff could be more exact by stating :

"In effect, the server GC is tuned for maximizing throughput rather than minimizing incidents of latency."

JimboT  Feb 20, 2011 
Printed Page 490
Second clause of last full sentence on page

This sentence says :

"... forcing collection can hurt performance by unnecessarily promoting Gen0 objects to Gen1."

Shouldn't this sentence also state :

"... forcing collection can hurt performance by unnecessarily promoting Gen0 objects to Gen1 (and Gen1 objects to Gen2)."

JimboT  Feb 20, 2011 
Printed Page 503
Method 'ShowMessage'

The body should read

if (message == null) throw new ArgumentNullException("message");

not "message != null".

Andres Rohr  Jul 24, 2011 
Printed Page 514
Throughout "Preconditions and Overridden Methods"

Everywhere I see "overridden" on this page, and on page 516 in "Postconditions and Overridden Methods", it seems wrong. I believe "overriding" is correct.

"You keep using that word. I do not think it means what you think it means." -- Inigo Montoya

Anonymous  Jan 11, 2011 
Printed Page 524
"Debugger Integration" section

DbgCLR(.exe) has not been included in the .NET Framework SDKs since v3.5. The last SDK it was included in was v2.0's SDK. Mdbg is a managed debugger included in the .NET 4.0 Framework SDK, but it is a command-line app, not a GUI app. Google the term "DbgCLR" to learn more. Also see this post :

http://blogs.msdn.com/b/andypennell/archive/2005/02/21/377621.aspx

JimboT  Feb 15, 2011 
Printed Page 524
"Debugger Integration" section

Regarding the absence of the free GUI debugger DbgCLR(.exe) in SDKs past v2.0, pages found in Google about DbgCLR suggest downloading the free Visual Studio Express to get a CLR debugger with a GUI interface. Of course, the Express edition is not stripped down to just the debugger. Also, the lifetime of the Express edition is limited.

JimboT  Mar 10, 2011 
Printed Page 524
"Debugger Integration" section

The Visual Studio 2010 Integrated Shell (but not the Isolated Shell) also appears to contain the Visual Studio debugger. This could be a useful alternative to downloading the (temporary) instance of Visual Studio Express. The description of it says :

"By using the Visual Studio Shell (integrated mode), you will not need to make Visual Studio a prerequisite on your user machines."

I have verified this by installing the Integrated Shell on a machine that did not have Visual Studio installed. It can be downloaded from here :

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=115

JimboT  Oct 14, 2011 
Printed Page 584
WebClient section

Should a footnote be added, warning not to confuse the WebClient class in System.Net namespace with the WebClient class in Silverlight's subset of the .NET Framework?

JimboT  Feb 24, 2011 
Printed Page 585
First sentence of Note

This sentence states :

"...(this allows it to be sited in Visual Studio's designer)."

As with suggestions I made for pages 852 and 870, it would be more explicit to state :

"...(this allows it to be sited in the Visual Studio designer panel's component tray)."

JimboT  Feb 24, 2011 
Printed Page 597
in the function Listen()


Should "context.response.ContentLength64 = " read

"context.response.ContentLength = " ?

Frank J. Reashore  Oct 28, 2010 
Printed Page 614
middle of page

"At a minimum: * Add the [DataContract] attribute to each type.



MSDN says:

http://msdn.microsoft.com/en-us/library/ms733127.aspx

"By default, the DataContractSerializer infers the data contract and serializes all publicly visible types. All public read/write properties and fields of the type are serialized."


If I understand this correctly, C# In a Nutshell misleads readers into believing serialization is much harder that it really is.

Nathan Finstein  May 31, 2012 
Printed Page 681
2nd Paragraph , Line 1

A missing 'a' in assembly
Line says "The compiled code in an ssembly"

Chris Henderson  May 30, 2012 
Printed Page 741
First and last sentences of 3rd paragraph up from bottom

Single dispatch is explained in the preceeding paragraphs. The last sentence of the 3rd paragraph from the bottom states :

"..., only the runtime type of the receiver can vary which method gets called."

Shouldn't this sentence say :

"... only the compile-time type of the receiver can vary which method gets called."


The first sentence of the 3rd paragraph from the bottom states :

"The runtime decision of whether of whether to invoke a dog's Walk method or a cat's Walk method ..."

Unfortunately, it is the following, 2nd sentence that develops the fact that the decision is made at compile-time, not runtime. Nonetheless, should the first sentence be more exact and say :

"The compile-time decision of whether of whether to invoke a dog's Walk method or a cat's Walk method ..."

JimboT  Feb 21, 2011 
Printed Page 754
Second and third sentences of first paragraph that follows the two-paragraph tip at the top

These sentences state :

"The result of Intersect is (italic font) less restrictive when Demanded, requiring (italic font) intersected permissions to be met.
The result of Union is (italic font) more restrictive when Demanded, requiring both permission sets to be met."

According to Visual Studio 2010's Help, the italicized words should be in the other respective sentences. Also, in the 2nd clause of the third sentence should have the opposite meaning. These sentences should read :

"The result of Intersect is (italic font) more restrictive when Demanded, requiring (italic font) intersected permissions to be met.
The result of Union is (italic font) less restrictive when Demanded, requiring (italic font) either one of or both permission sets to be met."

JimboT  Feb 21, 2011 
Printed Page 761
Third sentence of paragraph after GetTVRoomKey method

This sentence states :

"A Demand can become particularly wasteful if a security-critical method is called in a loop - perhaps from another trusted assembly in the Framework."

Should this sentence be more explicit and say :

"... - perhaps from another fully (not partially) trusted assembly in the Framework."

JimboT  Feb 24, 2011 
Printed Page 761
Sixth sentence of paragraph after GetTVRoomKey method

This sentence states :

"To maintain security, methods that call link-demanded methods must themselves perform demands or link demands - ..."

Should this be more precise and say :

".. methods that call link-demanded methods must themselves perform demands or link demands on THEIR immediate caller - ..."

JimboT  Feb 24, 2011 
Printed Page 762
First sentence of paragraph before second set of bullet points in the middle of the page

This sentence states :

"Partially trusted assemblies can never call security critical methods in fully trusted assemblies."

It would be more exact (albeit lengthier) to state :

"Methods in partially trusted assemblies can never call security critical methods in fully trusted assemblies."

JimboT  Feb 21, 2011 
Printed Page 763
Tip about methods that are considered dangerous, but are not actually dangerous

A list of ALL such methods that cannot be abused, and which can be marked with [SecuritySafeCritical] would be useful. Would MSDN have any such list? A URL would be just as helpful.

JimboT  Mar 01, 2011 
Printed Page 767
First sentence of second paragraph up from bottom

This sentence states :

"This works well as long as all partaking assemblies do the same thing - ..."

Shouldn't this say :

"This works well as long as all the methods in other assemblies that call of your method do the same thing - ..."

JimboT  Feb 24, 2011 
Printed Page 768
First sentence of second bullet points in the set of bullet points at the top

This sentence states :

"Write [SecuritySafeCritical] wrappers around calls to X."

It would be more exact to state :

"Write [SecuritySafeCritical] wrappers around calls (by methods in assembly T) to methods in assembly X."

JimboT  Feb 21, 2011 
Printed Page 768
First sentence of first bullet point

This sentence states :

"Go fully critical yourself."

Would it be clearer to state :

"Make your assembly T fully critical."

JimboT  Feb 24, 2011 
Printed Page 768
First sentence of second bullet point

This sentence states :

"Write [SecurityCritical] wrappers around calls to X."

It would be more explicit to state :

"Write [SecurityCritical] wrappers around the methods in assembly T's calls to methods in X."

JimboT  Feb 24, 2011 
Printed Page 768
Third sentence up from the bottom

This sentence states :

"In other words, it's now entirely up to the host as to how permissions should be restricted - ..."

It would be more explicit to include examples, as in this version (if my understanding is correct) :

"In other words, it's now entirely up to the host (such as ASP.NET or an application domain) as to how permissions should be restricted - ..."

JimboT  Feb 24, 2011 
Printed Page 769
"Sandboxing Another Assembly" section

On page 954, in the second sentence of the paragraph after the tip, this section is referenced. It might be helpful to add a footnote on pg. 769 that references the "Isolating Types and Assemblies" section on pg. 954.

JimboT  Feb 24, 2011 
Printed Page 770
First sentence of tip at the top

The first sentence states :

"You can also pass a list of assemblies to fully trust into the CreateDomain method."

First, an array is passed, not a list. This could be confused with the List<T> collection. Secondly, what is passed are strong names that represent the assemblies, not the assembly file names. Third, MUSTN'T an array ALWAYS be passed (that is at least empty), rather than the weaker "CAN"?

JimboT  Feb 22, 2011 
Printed Page 801
Second sentence of tip at the bottom

The second sentence starts with :

"(If you don't call Wait and abandon the task, ..."

This clause is a little ambiguous. It could be taken to mean that if BOTH wait is not called and the task is not abandoned. It would be clearer to say :

"(If you don't call Wait, but instead abandon the task, ..."

JimboT  Feb 22, 2011 
Printed Page 820
Static methods section

The heading "Static methods" should be "Static members".

JimboT  Feb 22, 2011 
Printed Page 820
Last sentence of 2nd paragraph of Static methods (mmebers) section

This sentence starts off with :

"In other words, by making static methods thread-safe, ..."

This should instead be :

"In other words, by making static members thread-safe, ..."

JimboT  Feb 22, 2011 
Printed Page 821
First sentence of tip at the top

This sentence states :

"..., it pays to be cautious in assuming whether a method is read-only in nature."

It instead state :

"..., it pays to be cautious in assuming whether a member is read-only in nature."

JimboT  Feb 22, 2011 
Printed Page 824
lock (_locker ProgressStatus) status = _status;

There is a syntax error on this line. lock (_locker ProgressStatus) isn't even valid syntax. Furthermore, the _locker variable doesn't exist in this context. Finally, within the lock statement, you are assigning a reference to a reference type, which does not require locking. I am under the impression that the type ProgressStatus (from the same page) was meant to be a struct, such that assignment would perform an implicit copy.

Travis Parks  Oct 16, 2010 
Printed Page 824
last code segment

for this code segment, I am reading:

ProgressStatus status;
lock (_locker ProgressStatus) status = _status; // Again, a brief lock
int pc = statusCopy.PrecentComplete;
int msg = statusCopy.StatusMessage;


My thoughts:
For clarity, statusCopy should be created/defined somewhere but I don't see it. It makes me think that the important bold section of this segment, is incorrect; that instead of:

lock (_locker ProgressStatus) status = _status,

it should be

lock (_statusLocker) statusCopy = _status.

Also as a corollary, status should only be created once (its is created in with var statement in previous segment and then again in this segment).

I am reading 4th edition Jan 2010
I like this book very much!
Steve

Steve D'Sa  Nov 01, 2011 
Printed Page 831
Third sentence of first full paragraph on page

The third sentence states :

"A simple read or write on a field of 32 bits or less in always atomic."

This assumes that the 32-bit field is properly aligned on an address that is evenly divisible by 4 bytes, without a remainder. If a 32-bit field were not aligned, then two instructions would be required, which would not be atomic.

Note from the Author or Editor:
The CLR aligns fields on 4-byte boundaries, so this should never happen. An interesting point is that you could use [System.Runtime.InteropServices.FieldOffset] to a struct to create non-aligned fields. This is getting pretty obscure, though!

JimboT  Feb 22, 2011 
Printed Page 834
Figure 21-2

In the upper line for the Main thread, after the 1000 millisecond sleep completes, the Set method of "wh" is called. Is this an intentional abbrieviation of the member "_waitHandle" in the code on pg. 833, or is it a typo?

Note from the Author or Editor:
It's an abbreviation for _waitHandle

JimboT  Feb 22, 2011 
Printed Page 840
Second sentence of tip at the top

The second sentence states :

"The main thread of a WPF or Windows application, for example, ..."

I believe what is meant is :

"The main thread of a WPF or Windows Forms application, for example, ..."

I assume Windows console apps were not meant to be included.

JimboT  Feb 22, 2011 
Printed Page 852
Last bullet point in the "BackgroundWorker" section

This bullet point states :

"An implementation of IComponent allowing it to be sited in Visual Studio's designer"

To be clearer, this would be in the Component Tray at the bottom of Visual Studio's designer.

JimboT  Feb 22, 2011 
Printed Page 862
1st code listing on double-checking locking

Printed, pg 862 on double-checked locking code listing:
volatile Expensive _expensive;
public Expensive Expensive
{
get
{
if (_expensive == null)
{
var expensive = new Expensive();
lock(_expenseLock) if(_expensive == null) _expensive = expensive;
}
return _expensive;
}
}


In albahari.com the code is different and correct:
volatile Expensive _expensive;
public Expensive Expensive
{
get
{
if (_expensive == null) // First check (outside lock)
lock (_expenseLock)
if (_expensive == null) // Second check (inside lock)
_expensive = new Expensive();
return _expensive;
}
}

kchow8  Jul 28, 2011 
Printed Page 870
First bullet point

This bullet point states :

"A Component implementation, allowing it to be sited in Visual Studio's designer"

It should state :

"An IComponent implementation, allowing it to be sited in the Visual Studio designer's component tray". See the correction for pg. 852.

JimboT  Feb 22, 2011 
Printed Page 872
First sentence of first paragraph

This sentene has the same mistake as on pg. 871. The first sentence states :

"Both are like System.Timers in the members that they expose (Interval, Tick, Start, and Stop) and are used in a similar manner."

While class System.Timer.Timer does have Interval, start, and Stop members, it does not have an event named "Tick", but rather an event named "Elapsed".

JimboT  Feb 22, 2011 
Printed Page 888
Second set of bullet points, first bullet item

This bullet point states :

"If the query starts with Enumerable.Range, replace the latter with ParallelEnumerable.Range."

There is no "former" in the first clause of this sentence, unless it is supposed to be "the query". It would be clearer to say :

"... replace the start with ParallelEnumerable.Range."

JimboT  Feb 22, 2011 
Printed Page 892
Section titled "Parallel.Invoke"

To be explicit, an aside or footnote should be added saying that Parallel.Invoke should not be confused with P/Invoke (interop).

JimboT  Feb 27, 2011 
Printed Page 919
3rd line of code in method EnqueueTask

"tcs" (an instance of TaskCompletionSource) is in bold type on the first and 3rd lines. Therefore, shouldn't it also be in bold on the second line, where it is an argument to the constructor of WorkItem?

JimboT  Feb 22, 2011 
Printed Page 933
First sentence after code

The first sentence states :

"This program will handle 1,000 concurrent requests on fewer than 10 pooled threads."

However, the first executable statement in method Serve in class Server on pg. 932 is :

ThreadPool.SetMINThreads (50, 50);

Therefore, shouldn't the first sentence state :

"... on as few as 50 pooled threads."

JimboT  Feb 22, 2011 
Printed Page 954
12th line

the signature seemingly should be that of CreateInstanceAndUnwrap, instead of CreateInstanceFromandUnwrap

Ting Xing  Jun 13, 2011 
Printed Page 957
First sentence of second paragraph, after section title "Calling into Native DLLs"

Add a footnote somewhere warning not to confuse P/Invoke (interop) with Parallel.Invoke.

JimboT  Mar 01, 2011 
Printed Page 958
2nd paragraph

All UnmanagedType members are listed at the end of this chapter

I can't find this list on my copy

Vincent Croquette  Mar 09, 2011 
Printed Page 998
Between [AllowPartiallyTrustedCallers] and anchors index entries

Should there be an entry in the index for "ambient property" on pg. 152? This introduces the concept of WPF's property inheritance.

JimboT  Feb 22, 2011 
Printed Page 999
Basic Multiclingual Plane

This should be "Basic Multilingual Plane".

JimboT  Feb 22, 2011 
Printed Page 1002
omission

It might be helpful to include the term "constructor initializer" in the index even though it is never used in the text near where the concept is introduced.

constructors, initializers, (base) 83, (this) 66

Anonymous  Jan 11, 2011 
Printed Page 1002
Between ContainsKey method and contextual keywords

Should there be an entry in the index for "ContextBoundObject" on pg. 818?

JimboT  Feb 22, 2011 
Printed Page 1004
Index, 1st column, 60% down.

"lambda" typo (as "lambca")

"delgates" => "lambda expressions (see lambca expressions)".

arodriguez  Jun 13, 2011 
Printed Page 1007
extern modifier

"Extern" is also discussed on pg. 766

JimboT  Feb 22, 2011 
Printed Page 1008
Between function members and functional purity

Should there be an entry in the index for "functional construction" on pg. 418?

JimboT  Feb 23, 2011 
Printed Page 1008
functional purity

Add pages 420 and 510 as an index entry. Of course, the purity discussed on pg. 510 is not about PLINQ.

JimboT  Feb 23, 2011 
Printed Page 1009
Between IComparer interface and identifiers

Should there be an entry for "IComponent, Visual Studio component tray" on pages 852 and 870?

JimboT  Feb 23, 2011 
Printed Page 1009
immutable objects

Immutable objects are also referred to on pg. 253.

JimboT  Feb 23, 2011 
Printed Page 1009
New entry for IComponent, between IComparer interface and identifiers

Add a reference to pg. 585 for IComponent in the index.

JimboT  Feb 24, 2011 
Printed Page 1016
properties

(Ambient) properties are also discussed on pg. 152.

JimboT  Feb 23, 2011 
Printed Page 1018
column 2, very bottom

Under index entry for "signaling", the 2nd sub-entry says :

"with Wait and Pulse (see Wait and
Pulse1)"

this should be :

"with Wait and Pulse (see Wait and
Pulse)"

JimboT  Dec 01, 2010 
Printed Page 1023
2nd column, index entry for "WPF"

The index entry for "WPF" lists only pg. 188. However, the book also briefly mentions WPF on pages 492, 493, 822, 840, and 851, from what I've seen so far.

JimboT  Dec 01, 2010 
Printed Page 1023
Windows Forms

Windows Forms are also referred to on pages 493, 666, 670, 756, 791, 799, 814, 851-852, 840, 869-872, and 909.

JimboT  Feb 23, 2011 
Printed Page 1023
WPF

WPF/Windows Presentation Foundation is also referred to on pages 183, 234, 665-666, 670, 668, 756-757, 791, 799, 814, 852, 869-872, and 909.

JimboT  Feb 23, 2011