开发者

What is the Triplet class used for? Is it related to Tuples?

So I just learnt about the Triplet class. I have no experience with ASP.NET, only the core .NET Framework.

Can someone explain to me where/why the Triplet class exi开发者_开发技巧sts? Is it like a Tuple?


Yes, it's pretty much like Tuple from .NET 4.0, but dates back to .NET 1.0 and ASP.NET 1.0 in particular. It's primarily used in ViewState serialization:

The Page class contains a SavePageViewState(), which is invoked during the page life cycle's save view state stage. The SavePageViewState() method starts by creating a Triplet that contains the following three items:

  1. The page's hash code. This hash code is used to ensure that the view state hasn't been #tampered with between postbacks. We'll talk more about view state hashing in the "View State and Security Implications" section.
  2. The collective view state of the Page's control hierarchy.
  3. An ArrayList of controls in the control hierarchy that need to be explicitly invoked by the page class during the raise postback event stage of the life cycle.

There's also its' younger brother called Pair.

There's absolutely no reason you should even bother about these classes or else an unholy untyped mess will ensue.


Sounds like it's got one more object than a Pair. You use it when you need to return exactly three items.

C# and Java are different from Python, which will convert multiple return values into a tuple.

A Triple does sound like a tuple to me - one that has exactly three items.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜