Author: Joseph & Ben Albahari
Publisher: O'Reilly, 2010
Audience: Programmers who occasionally use C#
Reviewer: Ian Elliot
With so much documentation available on the web. who will benefit from this slim book designed as "Instant Help for C# 5.0 Programmers"?
This small-format pocket reference on C# has been updated to cover C# 5. The big question, as before, is why do you want a pocket reference in this day of instant online information?
In this case it is because it is both concise and comprehensive. I read the previous editions of this particular guide from cover to cover in one sitting - something most readers won't do - and I have to say that it was a great way to make sure that I'd got C# into my head with no significant gaps. If you are an occasional C# user this is a good way to refresh your knowledge in double quick time.
While C# 5.0 is proclaimed on the cover, this deals with all the previous C# facilities up to and including version 5. However in this updated version two new sections are flagged as being specific to C# 5.0. These sections occupy 11 pages, but the book still has exactly the same number of pages overall. How has this been achieved?
The answer is that there are now more "numbered" pages and fewer preliminary ones. Previously there had been a detailed table of contents that took up seven pages. Now only the main headings are listed, using two pages. The index has also been slimmed down by about a third, from 17 to 11 pages which means that it still remains detailed enough to be useful. This is an interesting way of getting more data into the same space!
So what is new in this version. The section on Asynchronous Functions covers the await and async keywords and contrasts the way in which a synchronous method and its new asynchronous counterparts works. Having shown how to write an asynchronous function with async and await it notes that omitting await results in parallelism. The section rounds off with Asynchronous Lambda Expressions.
The other new section is on Caller Info Attributes and is included immediately before Asynchronous Functions making it look as though the new C# 5.0 material is gathered together. Not so - it's just that the new ability to tag optional parameters with one of three caller info attributes follows on from the existing section on Attributes - in fact it probably should be a sub-section within it.
There probably isn't enough new material in this edition to merit buying it is you have the previous edition. But for those who don't let's look at the other 95% of it.
It starts off looking at the very basic aspects of the language - keywords, variables, variable types, classes, methods and properties - and so on. All very carefully explained but here you find the shortcomings of any condensed presentation. Occasionally some advanced topic or other is mentioned in passing at the end of a section and you think "I didn't really understand that". A slightly worse position is when you don't really get the deeper implication of an idea because there isn't the space to emphasize it.
The book moves forward to more advanced topics - generics, delegates, events, lambdas, enumeration, operator overloading, extension methods and so on.
Then it makes an abrupt change of course and deals with Linq and Dynamic binding. Even though these are part of the language neither of them really seem to be part of the language in the same way that say generics are - it is probably just a matter time before they mature.
Next we reach attributes, described as "an extensible mechanism for adding custom information to code elements" and after looking at attribute classes, names and positional attribute parameters, attribute targets and so on the new material on caller info attributes is slotted in.
After the new section in asynchronous methods, the book closes with Unsafe code, Compiler directives and XML documentation.
If you are looking for a good and up-to-date pocket guide to C# this is it - just buy it. But don't expect a deep discussion of complex and subtle topics, this is the minimum presentation of what you need to know.