C# Tuple的用法

Tuple是返回多个参数,C# 4.0引入

最多支持8个参数,第八个参数是Tuple,意思就是参数多于8个就开始嵌套调用了

一个函数返回多个类型,这样就不在用out , ref等输出输入参数了,可以直接定义一个tuple类型就可以了。非常方便。

//
        // 摘要:
        //     Creates a new 2-tuple, or pair.
        //
        // 参数:
        //   item1:
        //     The value of the first component of the tuple.
        //
        //   item2:
        //     The value of the second component of the tuple.
        //
        // 类型参数:
        //   T1:
        //     The type of the first component of the tuple.
        //
        //   T2:
        //     The type of the second component of the tuple.
        //
        // 返回结果:
        //     A 2-tuple whose value is (item1, item2).
        public static Tuple<T1, T2> Create<T1, T2>(T1 item1, T2 item2);

private readonly Tuple<int, int>[] _updateLoopRetryDelays = new [] {
            Tuple.Create(0, 3),    // 0ms x 3
            Tuple.Create(10, 3),   // 10ms x 3
            Tuple.Create(50, 2),   // 50ms x 2
            Tuple.Create(100, 2),  // 100ms x 2
            Tuple.Create(200, 2),  // 200ms x 2
            Tuple.Create(1000, 2), // 1000ms x 2
            Tuple.Create(1500, 2), // 1500ms x 2
            Tuple.Create(3000, 1)  // 3000ms x 1
        };



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值