C# 4.0 in a Nutshell: The Definitive Reference

Author: Joseph Albahari, Ben Albahari
4.6
All Stack Overflow 10

C# 4.0 in a Nutshell: The Definitive Reference

4.6

Review Date:

Comments

by anonymous   2017-08-20

From the C# 4.0 in a Nutshell:


There are currently some practical limitations on what PLINQ can parallelize. These limitations may loosen with subsequent service packs and Framework versions. The following query operators prevent a query from being parallelized, unless the source elements are in their original indexing position:

  • Take, TakeWhile, Skip, and SkipWhile
  • The indexed versions of Select, SelectMany, and ElementAt

Most query operators change the indexing position of elements (including those that remove elements, such as Where). This means that if you want to use the preceding operators, they’ll usually need to be at the start of the query


So, in fact, using TakeWhile prevents the .AsParallel() from parallelizing. It is hard to say why Where kills the subscriptiion, but putting it before AsParallel might fix the problem.

by anonymous   2017-08-20

C# 4 is basically a superset of all the other versions, so if you know C# 4 then you definitely know the earlier versions. On the other hand, I think it's worth knowing what's in which version. I have a couple of "bluffer's guides" on my C# in Depth web site which give a bit of information about C# 2 and 3 - I'll do a similar one for C# 4 soon. See this question for a very brief list of features in each version.

As for migrating from C and C++ - try to ignore everything you think you know. Some bits will be similar, some will be completely different. You should try to work the way the language expects you to, rather than applying C++ idioms to it.

You might want to read Essential C# 4.0, C# 4.0 in a Nutshell or Accelerated C# 2010. My own book - C# in Depth - will have a second edition soon, covering C# 4, but it's really designed for people who already know C# 1.

by anonymous   2017-08-20

Jon Skeet has an entire chapter dedicated to them in the 2nd edition of C# in Depth. It's roughly 40 pages based on the last MEAP update. This isn't final since, as Joel mentioned, it's not out yet, but you could buy it and get access to the MEAP releases: http://www.manning.com/skeet2/

C# 4.0 in a Nutshell covers it in Ch. 13, "Diagnostics and Code Contracts." Based on the chapter headings in the table of contents I estimate ~17 pages on the topic.

I imagine Andrew Troelsen's Pro C# 2010 and the .NET 4 Platform book will cover it, but I wasn't able to find a TOC for it.