Pair and Triplet
Pair 类用作存储两个相关对象的基本结构。它是在整个 ASP.NET 中(在如页面状态管理任务期间或配置节处理程序的过程中)有多种用法的实用工具类。可以在自己的代码中需要包含两个相关对象的结构的任意位置和不一定需要数据绑定的位置使用 Pair 类。Pair 类不将其对象引用 First 和 Second 封装在属性中;该类直接将它们作为公共类字段公开到所有调用代码。
Pair 类在页状态保留实现中有多种用法。最常见的用法是同时作为 ViewState 和 ControlState 集合的容器。在这种情况下,First 属性用于 ViewState,而 Second 用于 ControlState。
[Serializable, AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class Pair
{
    // Fields
    public object First;
    public object Second;
    // Methods
    public Pair()
    {
    }
    public Pair(object x, object y)
    {
        this.First = x;
        this.Second = y;
    }
}
Triplet 类用作存储三个相关对象的基本结构。该类是一个在整个 ASP.NET 中以多种方式使用的实用工具类。可以在自己的代码中需要结构以包含三个相关对象的任意位置和不一定需要数据绑定的位置上使用 Triplet 类。Triplet 类不将其 object 引用(First、Second 和 Third)封装在属性中;该类直接将它们作为公共类字段公开到所有调用代码
[Serializable, AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class Triplet
{
    // Fields
    public object First;
    public object Second;
    public object Third;
    // Methods
    public Triplet()
    {
    }
    public Triplet(object x, object y)
    {
        this.First = x;
        this.Second = y;
    }
    public Triplet(object x, object y, object z)
    {
        this.First = x;
        this.Second = y;
        this.Third = z;
    }
}
                    
                


    
                
            
        
浙公网安备 33010602011771号