.net - 带有 RX 扩展的 LINQ

标签 .net vb.net linq system.reactive

我的印象是 LINQ 查询语言适用于 IObservable,就像它适用于带有 ReactiveExtensions 的 IEnumerable 一样。我有以下代码

Public Sub Foo(source As IObservable(Of Tuple(Of Integer, Integer)))
  Dim filtered = source.Where(Function(x) x.Item1 > 10).Select(Function(x) x.Item1 + x.Item2)
  Dim filtered2 = From x In source Where x.Item1 > 10 Select x.Item1 + x.Item2
End Sub

Public Sub Bar(source As IEnumerable(Of Tuple(Of Integer, Integer)))
  Dim filtered = source.Where(Function(x) x.Item1 > 10).Select(Function(x) x.Item1 + x.Item2)
  Dim filtered2 = From x In source Where x.Item1 > 10 Select x.Item1 + x.Item2
End Sub

IEnumerable 版本的代码是可以的。但是对于 Foo 的 LINQ 版本(第二行)
我收到后期绑定(bind)不允许错误
x.Item1

当我将鼠标悬停在 上时x Intellisense 说它是对象类型而不是
类型元组。但是对象查询版本相同的操作(第一行)
编译正常。我已经进口了
Imports system.reactive.linq

我错过了另一个引用吗?

最佳答案

问题中的所有代码对我来说都很好。我不明白你的错误。

也许尝试导入 System.Reactive也是,但除此之外它看起来还不错。

关于.net - 带有 RX 扩展的 LINQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13196159/

相关文章:

c# - .Net ORM 具有最快的学习曲线?

.NET 3.5 中的 C# 不序列化 Java Web 服务公开的 ENUM

c# - 系统.Runtime.Remoting.RemotingException : Requested Service not found

.net - ASP.NET MVC 路由和文件路径

.net - 将 IQueryable<T> 序列化到 session 状态服务器

c# - 使用 LINQ to dictionary 新建字典

c# - .Sort(Function(x, y) -> 当没有要排序的内容时重新排列列表(即所有排序字段具有相同的值)

asp.net - 遍历文本框和标签

vb.net - 如何动态调用函数

c# - 左连接 linq to sql