So I just learnt about the Triplet
class. I have no experience with ASP.NET, only the core .NET Framework.
所以我刚刚了解了Triplet课程。我没有使用ASP.NET的经验,只有核心.NET Framework。
Can someone explain to me where/why the Triplet class exists? Is it like a Tuple?
有人可以向我解释Triplet类存在于何处/原因?它像一个元组?
2 个解决方案
#1
8
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:
是的,它与.NET 4.0中的Tuple非常相似,但特别是可以追溯到.NET 1.0和ASP.NET 1.0。它主要用于ViewState序列化:
The Page class contains a
SavePageViewState()
, which is invoked during the page life cycle's save view state stage. TheSavePageViewState()
method starts by creating aTriplet
that contains the following three items:Page类包含一个SavePageViewState(),它在页面生命周期的保存视图状态阶段调用。 SavePageViewState()方法首先创建一个包含以下三项的Triplet:
- 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.
页面的哈希码。此哈希代码用于确保视图状态未在回发之间进行#tampered。我们将在“视图状态和安全性含义”部分中详细讨论视图状态哈希。
- The collective view state of the
Page
's control hierarchy.Page的控件层次结构的集合视图状态。
- 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.控件层次结构中的控件的ArrayList,需要在生命周期的raise backback事件阶段由页面类显式调用。
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.
绝对没有理由你甚至不应该为这些课程而烦恼,否则就会产生一种不圣洁的乱七八糟的混乱局面。
#2
1
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.
C#和Java与Python不同,后者将多个返回值转换为元组。
A Triple does sound like a tuple to me - one that has exactly three items.
Triple对我来说听起来像一个元组 - 一个正好有三个项目。
#1
8
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:
是的,它与.NET 4.0中的Tuple非常相似,但特别是可以追溯到.NET 1.0和ASP.NET 1.0。它主要用于ViewState序列化:
The Page class contains a
SavePageViewState()
, which is invoked during the page life cycle's save view state stage. TheSavePageViewState()
method starts by creating aTriplet
that contains the following three items:Page类包含一个SavePageViewState(),它在页面生命周期的保存视图状态阶段调用。 SavePageViewState()方法首先创建一个包含以下三项的Triplet:
- 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.
页面的哈希码。此哈希代码用于确保视图状态未在回发之间进行#tampered。我们将在“视图状态和安全性含义”部分中详细讨论视图状态哈希。
- The collective view state of the
Page
's control hierarchy.Page的控件层次结构的集合视图状态。
- 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.控件层次结构中的控件的ArrayList,需要在生命周期的raise backback事件阶段由页面类显式调用。
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.
绝对没有理由你甚至不应该为这些课程而烦恼,否则就会产生一种不圣洁的乱七八糟的混乱局面。
#2
1
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.
C#和Java与Python不同,后者将多个返回值转换为元组。
A Triple does sound like a tuple to me - one that has exactly three items.
Triple对我来说听起来像一个元组 - 一个正好有三个项目。