Click or drag to resize
ElementCollectionTCastTElement Method
Gets the element at the specified index and casts it to the specified type.

Namespace: GemBox.Document
Assembly: GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1231
Syntax
public TElement Cast<TElement>(
	int index
)
where TElement : 

Parameters

index
Type: SystemInt32
The zero-based index of the element to get.

Type Parameters

TElement
The type to cast the element to.

Return Value

Type: TElement
The element at the specified index casted to TElement type.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionindex is less than 0 or is equal to or greater than Count.
InvalidCastExceptionAn element at the specified index cannot be cast to type TElement.
Remarks
This method serves as a utility method for casting. Default C# explicit casting, when used in a chain, makes code hard to write and read. This method makes the chain casting code more clear and maintainable.
See Also