C#LINQ查询语法奇怪

时间:2014-03-20 13:55:58

标签: c# linq

这是一个简单的场景:

   var q = from i in icdPatientList
                        group i by i.PatientId into grp
                        select new
                        {
                            Key = grp.Key,
                            //trailing comma causes no compile-time error
                            Count = grp.Count(),
                        };
                foreach (var item in q)
                {
                    //simple columns + counts
                    Console.WriteLine(item.Key + " " + item.Count);

                }

为什么在投影中有一个尾随逗号后没有任何内容,它不会导致编译时错误?有两个逗号,当然也没有完美的作品。

0 个答案:

没有答案