What is the Triple class used for? Is this related to tuples?

So, I just found out about the Triplet class. I have no experience with ASP.NET, but only with the main .NET Framework.

Can someone explain to me where / why Triplet class exists? Does it look like a Tuple?

+6
source share
2 answers

Yes, this is very similar to Tuple from .NET 4.0, but goes back to .NET 1.0 and ASP.NET 1.0 in particular. It is mainly used in Serializing ViewState :

The page class contains SavePageViewState() , which is called during the state phase of the page lifecycle state. The SavePageViewState() method begins by creating a Triplet , which contains the following three elements:

  • The hash code of the page. This hash code is used to ensure that the state of the view has not been # redirected between postbacks. We’ll talk more about state hashing state in the State and Security State section.
  • State of collective representation of the hierarchy Page .
  • ArrayList of controls in the control hierarchy that must be explicitly called by the page class during the lifecycle postback event retry phase.

There is also his "little brother" called Pair .

There is absolutely no reason why you should even worry about these classes, otherwise an unholy, untyped mess will occur.

+8
source

It looks like he has one more object than a couple. You use it when you need to return exactly three elements.

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

The three sounds like a tuple to me - one that has exactly three elements.

+1
source

Source: https://habr.com/ru/post/886137/


All Articles