If you are not familiar with this feature, why not read up on it? Is this a homework or interview question? If it is, then we can't help without simply giving you the answer.
But you don't actually need to be familiar with this in order to have a good attempt at answering anyway. I'm not, but one of these options just looks like there is no way it could possibly work in parallel.
I'm studying electrical engineering, so this language is not so useful for me. I Don't really have the time to learn it, unfortunately.
Im participating in a competition with me co-students, to win music festival tickets, i need to use my network and solution finding skills in order to answer all the questions, therefore i was hoping that you could simply give me the correct answer..
Anyways, i found out that the answer was B..
But now i have gotten a new question, i hope you can help me:
/Kippers
Last edited by Cimperiali; April 17th, 2012 at 07:01 AM.
Reason: image attached here
I'm studying electrical engineering, so this language is not so useful for me. I Don't really have the time to learn it, unfortunately.
Im participating in a competition with me co-students, to win music festival tickets, i need to use my network and solution finding skills in order to answer all the questions, therefore i was hoping that you could simply give me the correct answer..
Anyways, i found out that the answer was B..
(with highlights in red added by me)
Yes, B is correct. But you don't actually need to learn this topic in order to answer this question - there is more to 'solution finding skills' than direct knowledge of the topic in question. Before I read this thread, I didn't know anything about PLINQ but I could still answer the question using a bit of logic. This is how I approached it:
1) The question implies that all four code fragments compile, but one of them will not run in parallel.
2) With that in mind, assuming 'Parallel.ForEach' does what the name implies (i.e. runs a foreach loop in parallel) then A will run in parallel.
3) Assuming C and D both compile, they look as if they should do exactly the same thing (just coded in a different style). Therefore these either both run in parallel or neither runs in parallel. As the question says only one answer doesn't, then both must be parallel.
4) So by a process of elimination, case B must not run in parallel, so is the answer.
Also, this line (from case B) just looks funny:
Code:
foreach (var item in collection.AsParallel())
Clearly the AsParallel() method is intended to somehow arrange for access to the collection in parallel. But the only way I could imagine this could work would be to then have a further method called on the result of this (as in C and D). Just having it on it's own in the foreach line doesn't seem correct.
You can see that none of this reasoning requires any more knowledge of this subject than that which is in the question. All it needs is a bit of logic.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.