You are creating a Windows Forms application by using the .NET Framework 3.5.
The application stores a list of part numbers in an integer-based array as shown in the following code segment. (Line numbers are included for reference only.)
01 var parts = new int[]
02 { 105, 110, 110, 235, 105,
03 135, 137, 205, 105, 100, 100 };
04
05 foreach (var item in results) {
06 tbResults.Text += item + "rn";
07 }
You need to use a LINQ to Objects query to perform the following tasks:
* Obtain a list of duplicate part numbers.Order the list by part numbers.
* Provide the part numbers and the total count of part numbers in the results.
Which code segment should you insert at line 04?
A.
var results = (from n in parts orderby n group n by n into n1 select new {
n1.Key, count = n1.Count() }).Distinct();
B.
var results = (from n in parts group n by n into n1 where n1.Count() > 1 orderby n1 select new {
n1.Key, count = n1.Count() });
C.
var results = (from n in parts orderby n group n by n into n1 where n1.Count() > 1 select n1);
D.
var results = (from n in parts orderby n group n by n into n1 where n1.Count() > 1 select new { n1.Key, count = n1.Count() });