Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 从LINQ(VB)向jQuery传递索引_Vb.net_Linq - Fatal编程技术网

Vb.net 从LINQ(VB)向jQuery传递索引

Vb.net 从LINQ(VB)向jQuery传递索引,vb.net,linq,Vb.net,Linq,我在VB LINQ语法方面遇到问题。我有一个将JSON返回到jQuery的web服务,我需要这些项的索引,但无法找到它 Dim newsItems = From news In newsItems.Skip((page - 1) * 1).Take(10) _ Select New With { _ .Title = news.Name, _ .Link = GetItemUrl(news) _ } 除了标题和链接,

我在VB LINQ语法方面遇到问题。我有一个将JSON返回到jQuery的web服务,我需要这些项的索引,但无法找到它

 Dim newsItems = From news In newsItems.Skip((page - 1) * 1).Take(10) _
        Select New With { _
           .Title = news.Name, _
           .Link = GetItemUrl(news) _
        }

除了标题和链接,我还想得到每个项目的索引。为了实现这一点,我应该添加什么?谢谢。

有一个重载
Select
扩展方法可以满足您的需要

试试这个:

Dim newsItems2 = _
    newsItems _
        .Skip((page - 1) * 1) _
        .Take(10) _
        .Select(Function (news, index) New With { _
           .Title = news.Name, _
           .Link = GetItemUrl(news), _
           .Index = index _
        })

我现在用C#编写代码,所以我希望语法正确。不应该很近。

好笑,没有人回答我的问题,所以我终于明白了。回到这里发布答案,并看到了这一点。你漏掉了一个右括号,但除此之外,正是我想到的。谢谢@威尔-谢谢。我突然插入了缺少的括号。:-)