Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Pair Class
Collapse the table of content
Expand the table of content

Pair Class

Provides a basic utility class that is used to store two related objects.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public sealed class Pair

The Pair type exposes the following members.

Public methodPair()Creates a new, uninitialized instance of the Pair class.
Public methodPair(Object, Object)Initializes a new instance of the Pair class, using the specified object pair.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Public fieldFirstGets or sets the first object of the object pair.
Public fieldSecondGets or sets the second object of the object pair.

The Pair class is used as a basic structure to store two related objects. It is a utility class that is used in various ways throughout ASP.NET, such as during page state management tasks or in configuration section handlers. You can use the Pair class in your own code anywhere that you need a structure to contain two related objects and where data hiding is not essential. The Pair class does not encapsulate its object references, First and Second, in properties; it exposes them directly to all calling code as public class fields.

The Pair class can be used in several ways in page state persistence implementations. The most common use is as a container for both the ViewState and ControlState collections. In this case, the First property is used for ViewState, and the Second for ControlState.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft