@@ -49,8 +49,8 @@ public static void RemoveWhere<T>(this ICollection<T> collection, Predicate<T> p
4949 /// <returns>The index of the item, or -1 if not found.</returns>
5050 public static int IndexOf ( this IEnumerable enumerable , object ? item )
5151 {
52- if ( enumerable is ICollection collection )
53- return collection . IndexOf ( item ) ;
52+ if ( enumerable is IList list )
53+ return list . IndexOf ( item ) ;
5454
5555 if ( enumerable is ICollectionView collectionView )
5656 return collectionView . IndexOf ( item ) ;
@@ -86,35 +86,35 @@ public static bool IsReadOnly(this IEnumerable enumerable)
8686
8787 public static void Add ( this IEnumerable enumerable , object ? item )
8888 {
89- if ( enumerable is ICollection collection )
90- collection . Add ( item ) ;
89+ if ( enumerable is IList list )
90+ list . Add ( item ) ;
9191
9292 if ( enumerable is ICollectionView collectionView )
9393 collectionView . Add ( item ) ;
9494 }
9595
9696 public static void Insert ( this IEnumerable enumerable , int index , object ? item )
9797 {
98- if ( enumerable is ICollection collection )
99- collection . Insert ( index , item ) ;
98+ if ( enumerable is IList list )
99+ list . Insert ( index , item ) ;
100100
101101 if ( enumerable is ICollectionView collectionView )
102102 collectionView . Insert ( index , item ) ;
103103 }
104104
105105 public static void Remove ( this IEnumerable enumerable , object ? item )
106106 {
107- if ( enumerable is ICollection collection )
108- collection . Remove ( item ) ;
107+ if ( enumerable is IList list )
108+ list . Remove ( item ) ;
109109
110110 if ( enumerable is ICollectionView collectionView )
111111 collectionView . Remove ( item ) ;
112112 }
113113
114114 public static void Clear ( this IEnumerable enumerable )
115115 {
116- if ( enumerable is ICollection collection )
117- collection . Clear ( ) ;
116+ if ( enumerable is IList list )
117+ list . Clear ( ) ;
118118
119119 if ( enumerable is ICollectionView collectionView )
120120 collectionView . Clear ( ) ;
0 commit comments