To me at least, the Pair class is a very multi-purpose class. So why did Microsoft put it into the System.Web.UI namespace?
Is there a reason that my tiny brain cannot comprehend?
Thanks.
To me at least, the Pair class is a very multi-purpose class. So why did Microsoft put it into the System.Web.UI namespace?
Is there a reason that my tiny brain cannot comprehend?
Thanks.
It is used to serialize viewstate (along with its cousin Triplet).
I would guess that the reason they are not part of the base library (even though there is nothing ASP.NET-specific about them) is that they are not very useful since they are untyped.
To include untyped pair and triplet in the base library, might be seen as encouraging "typeless" programming.
A typed tuple might be useful, though (and I think F# has them). I think anonymous types covers most of the use cases for heterogenous tuples though.
I don't think you're going to find a great reason. It seems as though it was first created by the web team, so they made it in their namespace/assembly. They also added a LinkDemand for AspNetHostingPermission, which is unfortunate.
In terms of its "expected use," MSDN says
[The Pair class] 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.
...
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.