0

我尝试将以下 linq 代码从 c# 转换为 vb.net。

var groupedPhotos = from photo in photos
                    orderby photo.TimeStamp
                    group photo by photo.TimeStamp.ToString("y") into photosByMonth
                    select new KeyedList<string, Photo>(photosByMonth);

当我按以下方式转换时,我收到一条错误消息,提示“范围变量名称只能从不带参数的简单名称或限定名称中推断出来”。我必须在哪里改变?

 Dim groupedPhotos = From photo In photos
                     Order By photo.TimeStamp
                     Group photo By photo.TimeStamp.ToString("y") Into Group 
                     Select New KeyedList(Of String, Photo)

提前致谢。

4

1 回答 1

0

试试那个:

Dim groupedPhotos = From photo In photos
                    Order By photo.TimeStamp
                    Group photo By Key = photo.TimeStamp.ToString("y") Into g = Group 
                    Select New KeyedList(Of String, Photo)(g)
于 2013-04-16T10:35:37.177 回答