Table of Contents

PageRange Class

Definition

Namespace
GleamTech.DocumentUltimate
Assembly
GleamTech.DocumentUltimate.dll

Represents a range of page numbers.

[TypeConverter(typeof(StringTypeConverter))]
public class PageRange : NumberRange
Inheritance
PageRange

Examples

Creating a PageRange instance:

var pageRange = new PageRange("1-5");

//Same as above, PageRange can be implicitly converted from a string
PageRange pageRange2 = "1-5";
Dim pageRange As New PageRange("1-5")

'Same as above, PageRange can be implicitly converted from a string
Dim pageRange2 As PageRange = "1-5"

Remarks

The range is specified as a string in the following forms or combination thereof:

5single value
1,2,3,4,5sequence of values
1-5closed range
-5open range (converted to a sequence from 1 to 5)
1-open range (converted to a sequence from 1 to final page)
allkeyword representing all page numbers.
oddkeyword representing odd page numbers.
evenkeyword representing even page numbers.

The value delimiter can be either ',' or ';' and the range separator can be either '-' or ':'. Whitespace is permitted at any point in the input.

Any elements of the sequence that contain non-digit, non-whitespace, or non-separator characters or that are empty are ignored.

Constructors

PageRange(string)

Initializes a new instance of the PageRange class from the specified string.

Methods

Add(int)

Adds a single page number to the sequence.

Add(int?, int?)

Adds a range of page numbers to the sequence. Reverse ordering is accepted.

Add(string)

Adds a range of page numbers to the sequence from a string representation (e.g. 1-5, 8, 11-13).

Enumerate(int)

Enumerates all the page numbers that this range instance describes. The sequence will be distinct and in ascending order.

Parse(string)

Converts a string containing the range of page numbers to a PageRange.

ToString()

Converts this instance to a string containing the range of page numbers.

Operators

implicit operator PageRange(string)

Converts a string containing the range of page numbers to a PageRange.

implicit operator string(PageRange)

Converts a PageRange to a string containing the range of page numbers.