Why a couple in System.Web.UI?

For me, at least the Pair class is a very multi-purpose class. So why did Microsoft put it in the System.Web.UI namespace?

Is there a reason my little brain can't understand?

Thanks.

+6
design class
source share
4 answers

I do not think you will find a great reason. It seems that this was first created by a web team, so they did it in their namespace / assembly. They also added LinkDemand to AspNetHostingPermission , which is unsuccessful.

In terms of "expected use", MSDN says

[ Pair Class] is a utility class that is used in various ways in ASP.NET, for example, during page state management tasks or in configuration section handlers.
...
The Pair class can be used in several ways in page state implementations. The most common use is as a container for ViewState and ControlState . In this case, the First property is used for ViewState and Second for ControlState .

+3
source share

Used to serialize the viewstate (along with its cousin triple).

I would suggest that the reason they are not part of the core library (although there is nothing ASP.NET specific to them) is that they are not very useful because they are untyped.

To include an untyped pair and a triplet in the base library can be seen as encouraging "impartial" programming.

The dialed tuple may be useful though (and I think they have F #). I think anonymous types cover most cases of using heterogeneous tuples.

+5
source share

This does not answer the question directly, but in .NET 4 you can probably use Tuple .

To answer the question, I believe that it was just a mistake to put Pair in System.Web.UI and Microsoft tried to resolve this error with the introduction of the Tuple class.

+3
source share

God forbid, we should have a typed pair, which is easier than a dictionary, and it can be poured into a typed list so that it is indexable :). Of course, creating one of them is painless, but why.

0
source share

All Articles