0 out of 2 rated this helpful - Rate this topic

Pair Class

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

System.Object
  System.Web.UI.Pair

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)
[SerializableAttribute]
public sealed class Pair

The Pair type exposes the following members.

  Name Description
Public method Pair() Creates a new, uninitialized instance of the Pair class.
Public method Pair(Object, Object) Initializes a new instance of the Pair class, using the specified object pair.
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public field First Gets or sets the first object of the object pair.
Public field Second Gets or sets the second object of the object pair.
Top

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, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Re: Why part 2?
>Why in the world doesn't this utterly obsolete class support generics.

Probably because this class dates back to .Net framework v1.0, whereas Generics weren't there until v2.0.
KeyValuePair
You are probably searching for the class KeyValuePair

 

Why part 2
Why in the world doesn't this utterly obsolete class support generics.
Even c++ has a pair class with generics, why can't c# have it?
Why?
Why in the world was this class placed in System.Web.UI? Why not in one of the more generic namespaces/libraries?