TimeSpanValidator Constructor (TimeSpan, TimeSpan, Boolean, Int64)


Initializes a new instance of the TimeSpanValidator class, based on supplied parameters.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public TimeSpanValidator(
	TimeSpan minValue,
	TimeSpan maxValue,
	bool rangeIsExclusive,
	long resolutionInSeconds


Type: System.TimeSpan

A TimeSpan object that specifies the minimum time allowed to pass validation.

Type: System.TimeSpan

A TimeSpan object that specifies the maximum time allowed to pass validation.

Type: System.Boolean

A Boolean value that specifies whether the validation range is exclusive.

Type: System.Int64

An Int64 value that specifies a number of seconds.

Exception Condition

resolutionInSeconds is less than 0.

- or -

minValue is greater than maxValue.

When the resolutionInSeconds parameter is specified, the TimeSpan object being validated must be equal to this value in order to pass validation.

The following code example demonstrates how to use the TimeSpanValidator constructor. This code example is part of a larger example provided for the TimeSpanValidator class.

// Create TimeSpan and Validator.
TimeSpan testTimeSpan = new TimeSpan(0,1,05);
TimeSpan minTimeSpan = new TimeSpan(0,1,0);
TimeSpan maxTimeSpan = new TimeSpan(0,1,10);
TimeSpanValidator myTimeSpanValidator = new TimeSpanValidator(minTimeSpan, maxTimeSpan, false, 65);

.NET Framework
Available since 2.0
Return to top