码迷,mamicode.com
首页 > Windows程序 > 详细

Errata for C# 6.0 in a Nutshell

时间:2019-03-15 23:04:42      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:between   lsp   col   possibly   missing   read   different   methods   prim   

Version

Location

Description

PDF

Page 15-16
list of reserved keywords and list of contextual keywords

The keyword ‘in‘ appears in both the reserved keyword list and the contextual keyword list.

Note from the Author or Editor:
The ‘in‘ keyword should appear only in the list of reserved keywords. Remove the ‘in‘ keyword from the list of contextual keywords.

Printed

Page 15
List after second paragraph.

Item "longnamespace" should be two different items "long" and "namespace".

PDF

Page 25
Paragraph under the heading: Bool Conversions

The Paragraph: "No conversion can be made from the bool type to numeric types or vice versa." I do not believe that this is the intent, I believe that the intent is "No casting conversion can be made from..." Thank you for your attention. --Avi

Printed

Page 29
Specialized Integral Operations -> Integral Division -> first paragraph

Keywords and identifiers in normal text are divided wherever the line ends - in this case ‘DivideByZeroException‘ is separated into ‘Divid‘ at the end of the second line of the paragraph and ‘eByZeroException‘ at the beginning of the third line. That‘s just one of numerous examples. My guess is, that the corresponding style description is broken (at least for print). These expressions should not be separatable _at_all_ in normal text except at blanks! To call it annoying is an understatement, because when happening at the right position I can only guess if it is meant to be two words or one expression instead ...

Note from the Author or Editor:
We should avoid breaking over literal-styled words where possible.

PDF

Page 36
2nd piece of code from bottom

The code: string a2 = @ "\\server\fileshare\helloworld.cs"; Should be: string a2 = @"\\server\fileshare\helloworld.cs";

Note from the Author or Editor:
Remove the space between the @ sign and the " symbol.

Printed

Page 37
Second paragraph in String Interpolation section

You discuss how to format an interpolated string in this section, but not how to pad it. However, you appear to demonstrate this feature much later (pg. 1050) without any discussion: Console.WriteLine($"{token.Kind(),-30} {token.Text}");

Note from the Author or Editor:
The cross-reference is incorrect. Change (format strings are described in "Formatting and Parsing” in Chapter 6) to: (format strings are described in "“String.Format and composite format strings” in Chapter 6)

PDF

Page 49
1st aside (caution or warning)

The text: just as though the parameter were mandatory. Should be: just as though the parameter was mandatory.

PDF

Page 49
3rd paragraph

There is typo in second word "nameSpace" "The namepace keyword defines a namespace"

Printed

Page 56
line 25

string s = (sb == null ? "nothing" : sb.ToString()); // the original line if (s == null) s = "nothing"; // this is missing // the original line is not strictly equivalent to the code line 23 because // when sb.ToString() returns null, s in line 23 is "nothing", in 25 is null

Note from the Author or Editor:
Delete the following text: The last line is equivalent to: string s = (sb == null ? "nothing" : sb.ToString());

PDF

Page 75
2nd paragraph

The text: A method’s signature comprises its name and parameter types Should also include order of parameters.

Note from the Author or Editor:
Change " parameter types" to " parameter types in order"

PDF

Page 101
Structs section, last para

this incurs a useful savings when should be: this incurs useful savings when or: this incurs a useful saving when

Note from the Author or Editor:
Change to "this incurs a useful saving when... "

Printed

Page 115
Example under 3rd paragraph

In the example that shows the effective substitution for Stack<int> the line: int[] data; should read: int[] data = new int[100] ;

PDF

Page 187
Paragraph under the heading Pointer Basics

Should the sixth word in "For every value type or pointer type V, there is a corresponding pointer type V*." be reference instead of pointer?

Note from the Author or Editor:
Correct. The sentence should read: "For every value type or reference type V...

PDF

Page 196
3rd paragraph from bottom

void Z(char[ ] 1, float[,] p2) {...} should be void Z(char[ ] a1, float[,] p2) {...}

PDF

Page 219
last para

CompareTo instance method or the static Compare and CompareOrdinal methods: these return a positive or negative number—or zero—depending on whether the first value comes before, after, or alongside the second. This is wrong because following two pages later is right. All of the order-comparison methods return a positive number, a negative number, or zero, depending on whether the first value comes after, before, or alongside the second value:

Printed

Page 233
Paragraph above the Warning box

Within the section "Formatting and parsing" on page 233 there is the text ‘ToString is overloaded to accept a format string and provider... We describe this in "Formatting and parsing on page 233." ‘ That should read: ‘We describe this in "Formatting and parsing" on page 240"

Printed

Page 570
General note under "Locking and Thread Safety"

The text says ‘For a full discussion, see ... and "Locking and Thread Safety‘ on page 570 in Chapter 22.‘ The page reference should be 912.

Printed

Page 585
1st paragraph of the notice.

At the end of the paragraph, "we wouldn‘t care if turns out..." should probably be "we wouldn‘t care if it turns out...".

Printed

Page 586
Last paragraph.

In the last phrase, "on page 585 in chapter 23.". Chapter 23 starts at page 945.

Note from the Author or Editor:
should read: "page 972 in Chapter 23."

PDF

Page 591
First paragraph

The expression, "course-grained" should be "coarse-grained". This error occurs more than once - e.g. on page 592, at the end of the paragraph starting, "Now we have a call graph", twice in the final paragraph of page 599 (although the heading to that section has the correct spelling), and in the final paragraph on page 620.

PDF

Page 593
method DisplayPrimeCountsFrom(int i)...

void DisplayPrimeCountsFrom (int i) { var awaiter = GetPrimesCountAsync (i*1000000 + 2, 1000000).GetAwaiter(); awaiter.OnCompleted (() => { Console.WriteLine (awaiter.GetResult() + " primes between..."); if (i++ < 10) DisplayPrimeCountsFrom (i); else Console.WriteLine ("Done"); }); } Here within awaiter.OnCompleted(()=>...), if(i++ <10) ... should be if(++i <10) instead. I am sure the author knows the difference between pre-increment and post-increment and it does make a difference here if the intent is to loop 10 times not 11 times.

PDF

Page 596
second to last paragraph

Upon first executing GetPrimesCount..., it should be GetPrimesCountAsync.

Printed

Page 772
First sentence in section ".resource Files"

The sentence "The Framwork also lets you add .resource files are... does not quite make sense. Possibly this should read "...add .resource files, which are..."

Printed

Page 861
end of first code block

ScriptEngine does not have a GetVariable method. The GetVariable method is defined on ScriptScope, and requires a single string argument specifying the name of the variable you wish to retrieve.

Note from the Author or Editor:
Yes, this needs to be updated to work with the latest version of IronPython. The last line of the first code listing on page 861 should read: Console.WriteLine (scope.GetVariable ("result")); // 6 instead of Console.WriteLine (engine.GetVariable (scope, "result")); // 6

Printed

Page 920
3rd paragraph

The text indicates that a number is appended to the list every second, but the argument passed to Thread.Sleep is only 100 (milliseconds), which is one tenth of a second.

Note from the Author or Editor:
In 3rd paragraph on page 920, change "every second" to "every 100ms".

Printed

Page 1058
5th paragraph

The word "this" is missing from the following sentence: "We can fix (this) by calling NormalizeWhitespace..."

Printed

Page 1059
2nd paragraph in CSharpSyntaxRewriter section

The first sentence in this paragraph refers to the section on the CSharpSyntaxWalker class as "SyntaxSyntaxWalker".

Note from the Author or Editor:
Replace SyntaxSyntaxWalker with CSharpSyntaxWalker

Printed

Page 1059
4th paragraph

The output shown is inconsistent with the call to NormalizeWhitespace on unit, which would insert carriage returns in the following locations in the output: after the semicolon, after "Program" and after the opening curly brace.

Note from the Author or Editor:
The code listing should be formatted as follows: var tree = CSharpSyntaxTree.Create (unit.NormalizeWhitespace()); Console.WriteLine (tree.ToString()); // Output: using System.Text; class Program { }

Printed

Page 1064
Code listing in 2nd paragraph

The expression location.MetadataModule == compilation.References.Single() evaluates to False, not True as indicated. This is consistent with the fact that the operands are of different types (IModuleSymbol and MetadataReference, respectively).

Note from the Author or Editor:
Thanks - will fix for next edition.

Printed

Page 1070
1st code block

While it does not affect the example, in the Program class in which symbols are renamed, the Foo declaration and usages are not consistent. Either the Foo call in Main should be static since it is defined statically, or the signature of Foo should be changed so that it is in fact an instance method and the instance call in Main can remain. This latter option also requires a change to the static call to Foo in Bar.

Note from the Author or Editor:
Thanks, will fix for next edition.

Errata for C# 6.0 in a Nutshell

标签:between   lsp   col   possibly   missing   read   different   methods   prim   

原文地址:https://www.cnblogs.com/tthua/p/10540034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!