Merge pull request #829 from symform/httpwebreq-async-ssl
[mono.git] / mcs / class / System.Core / System.Linq / Enumerable.cs
index ea5ff6e611b714e3e5ed19c1a9d3a9ce924bd70d..23805636c6b6236d00dc7b20fce0feeb83ffd659 100644 (file)
@@ -744,6 +744,12 @@ namespace System.Linq
                        if (list != null)
                                return list [index];
 
+#if NET_4_5
+                       var readOnlyList = source as IReadOnlyList<TSource>;
+                       if (readOnlyList != null)
+                               return readOnlyList[index];
+#endif
+
                        return source.ElementAt (index, Fallback.Throw);
                }
 
@@ -762,6 +768,12 @@ namespace System.Linq
                        if (list != null)
                                return index < list.Count ? list [index] : default (TSource);
 
+#if NET_4_5
+                       var readOnlyList = source as IReadOnlyList<TSource>;
+                       if (readOnlyList != null)
+                               return index < readOnlyList.Count ? readOnlyList [index] : default (TSource);
+#endif
+
                        return source.ElementAt (index, Fallback.Default);
                }