浏览代码

ElementAt: don't create exception after finding the item (#671)

David Karnok 7 年之前
父节点
当前提交
421e2a26ad
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAt.cs

+ 4 - 1
Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAt.cs

@@ -42,7 +42,10 @@ namespace System.Reactive.Linq.ObservableImpl
 
             public override void OnCompleted()
             {
-                ForwardOnError(new ArgumentOutOfRangeException("index"));
+                if (_i >= 0)
+                {
+                    ForwardOnError(new ArgumentOutOfRangeException("index"));
+                }
             }
         }
     }