KGy SOFT

EnumerableExtensionsTryRemoveRangeT Method (IEnumerableT, Int32, Int32, Boolean, Boolean)

KGy SOFT Core Libraries Help
Tries to remove count amount of items from the specified collection at the specified index.

Namespace:  KGySoft.CoreLibraries
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0
Syntax

public static bool TryRemoveRange<T>(
	this IEnumerable<T> collection,
	int index,
	int count,
	bool checkReadOnlyAndBounds = true,
	bool throwError = true
)

Parameters

collection
Type: System.Collections.GenericIEnumerableT
The collection to remove the elements from.
index
Type: SystemInt32
The zero-based index of the first item to remove.
count
Type: SystemInt32
The number of items to remove.
checkReadOnlyAndBounds (Optional)
Type: SystemBoolean
 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 (Optional)
Type: SystemBoolean
 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: .

Type Parameters

T
The type of the elements in the collections.

Return Value

Type: Boolean
, if the whole range could be removed from collection; otherwise, .

Usage Note

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).
Remarks

Removal is supported if collection is either an IListT or IList implementation.

See Also

Reference