【问题标题】:The type arguments cannot be inferred from the query RX无法从查询 RX 推断类型参数
【发布时间】:2013-08-18 03:30:37
【问题描述】:

在测试 SL 应用程序中考虑这一点(尝试学习 RX):

var input = (from _ in Observable.FromEventPattern(txt, "TextChanged")
                     select txt.Text)
            .Throttle(TimeSpan.FromSeconds(.05)).DistinctUntilChanged();

        var svc = new DictServiceSoapClient();

        var res = from term in input
                  from words in svc.MatchInDictAsync("wn", term, "prefix")
                  select words;

“from words in svc....”中的“from”显示错误消息:“无法从查询中推断类型参数。Try...”

我不明白它想说什么。我该如何解决这个问题?

【问题讨论】:

    标签: system.reactive


    【解决方案1】:

    编译器不知道将返回什么类型的 observable 'FromEventPattern',因为该方法使用反射来获取事件。您需要通过告诉它事件返回什么类型的对象来帮助它:

    Observable.FromEventPattern<TextChangedEventArgs>(txt, "TextChanged")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多