EnumerableExtensionsTryRemoveRangeT(IEnumerableT, Int32, Int32, Boolean, Boolean) Method
Tries to remove count amount of items from the specified collection at the specified index.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
public static bool TryRemoveRange<T>(
this IEnumerable<T> collection,
int index,
int count,
bool checkReadOnlyAndBounds = true,
bool throwError = true
)
<ExtensionAttribute>
Public Shared Function TryRemoveRange(Of T) (
collection As IEnumerable(Of T),
index As Integer,
count As Integer,
Optional checkReadOnlyAndBounds As Boolean = true,
Optional throwError As Boolean = true
) As Boolean
public:
[ExtensionAttribute]
generic<typename T>
static bool TryRemoveRange(
IEnumerable<T>^ collection,
int index,
int count,
bool checkReadOnlyAndBounds = true,
bool throwError = true
)
[<ExtensionAttribute>]
static member TryRemoveRange :
collection : IEnumerable<'T> *
index : int *
count : int *
?checkReadOnlyAndBounds : bool *
?throwError : bool
(* Defaults:
let _checkReadOnlyAndBounds = defaultArg checkReadOnlyAndBounds true
let _throwError = defaultArg throwError true
*)
-> bool
- collection IEnumerableT
- The collection to remove the elements from.
- index Int32
- The zero-based index of the first item to remove.
- count Int32
- The number of items to remove.
- checkReadOnlyAndBounds Boolean (Optional)
- to return if the target collection is read-only or the index is invalid; to attempt inserting the collection without checking the read-only state and bounds. This parameter is optional.
Default value: . - throwError Boolean (Optional)
- to forward any exception thrown by a found remove method; to suppress the exceptions thrown by the found remove method and return on failure. This parameter is optional.
Default value: .
- T
- The type of the elements in the collections.
Boolean, if the whole range could be removed from
collection; otherwise,
.In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Removal is supported if collection is either an IListT or IList implementation.
If
collection is neither a
ListT nor an
ISupportsRangeListT implementation,
then the elements will only be removed one by one.