The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

vc 74 (16) [Avatar] Offline
First of all thanks a lot for putting this together, C#2 brings back lots of good memories smilie

Page 5 How to construct delegates relatively easily1 (1 as a digit)

Page 5 For me the answer to this one is simple: C# 1 was a more productive language for many developers than Java was at the time.
Isn't it also because it was one of the languages of choice for .net development?
I was doing Delphi/C++ when .net was released and to me the transition to C# was natural in a Windows environment.

Page 9 I’m deliberately not going into the possibility of using interfaces for return types and parameters. That’s an interesting topic, but I don’t want to be distracted
from generics.
Definitely and interesting topic, it would be nice to have a section on this with the pros/cons of each possibility
(IEnumerable<T> and its potential performance traps in case GetEnumerator is called more than once, IReadOnlyList...)

page 24 Code formatting (curly brackets)

page 25: Enum itself isn't a value type either

page 25 Code formatting (curly brackets)

page 25: it also comes from making it harder to write broken code

Page 26: only place we’ve seen where the CLR needs understand Nullable<T> is to enforce the struct type constraint:
I guess by struct type constraint you mean the way the compiler constrains nullable types rather than `where T: struct`?

page 29: C# 7 has an even better solution for most cases where I’ve used the as operator with nullable value types.
But you can't use pattern matching with nullable types, can you?
If the value is null then there's nothing to match against and if it is not null, you can match against the underlying type instead of the nullable type.

page 34: For reference, EventHandler is has a signature of

page 35: Method group conversions save a few characters when create(ing?) a delegate instance (ing)

page 47: Code formatting (curly brackets)

page 56: you can then use then use
jon.skeet (483) [Avatar] Offline
Thanks for these; will get to them when I have a chance.
jon.skeet (483) [Avatar] Offline

Page 5 typo: "easily1" isn't in my Word document. I suspect this is a
MEAP production artifact.

Page 5 justification: that shifts from "why use C#" to "why use
.NET". I'm going to leave this as it is.

Page 9: unfortunately I just don't have space or time to go into
everything that could possibly be interesting. (Bear in mind that
the C# 2-4 coverage is deliberately slimmed down from the 3rd

Page 24/25/47 "code formatting": could you say exactly what you mean
about code formatting? (I don't actually have the MEAP edition; I'm
doing everything from the master document. If you can explain what
you mean without me having to *get* the MEAP document, it'll be a
lot simpler for me to check.)

Page 25: Enum bit: done

Page 25: It also comes...: done

Page 26: I mean the "where T : struct" constraint, that *doesn't*
include nullable value types, even though they're structs. So
Nullable<int> isn't a valid type argument for a type parameter
constrained by "where T : struct". That's something the CLR
enforces, as well as the compiler.

Page 29: You can match against a non-null value, e.g.

int? x = 50;
if (x is int y)
Console.WriteLine(y); // 50

Page 34: done

Page 35: done

Page 56: done
vc 74 (16) [Avatar] Offline
Sorry if I wasn't clear, some of these (p5, 9...) are just comments for which I don't expect you to change a single word smilie

The brackets' issue is a problem of indentation, for instance:

  public T Value
      if (!hasValue)
        throw new InvalidOperationException();
      return value;

jon.skeet (483) [Avatar] Offline
Ah, I suspect any formatting problem like that is with the manuscript -> MEAP system, probably where things cross page boundaries in the manuscript. I suspect there's nothing I can do to the manuscript for that, but obviously we'll make sure it all works out in the final version, where we have the "joy" of tweaking the spacing of every bit of it...
CeeKer (1) [Avatar] Offline
Page 38 Listing 2.9
object.someValueBoxed = someValue (instead of hasValue)
jon.skeet (483) [Avatar] Offline
Thanks - I've fixed listing 2.9.
Andrey Rebrin (2) [Avatar] Offline
Typo in code from "Extern aliases" chapter:

AltJObject = new AltJObject();
jon.skeet (483) [Avatar] Offline
Thanks - I've fixed that in my copy now.