当前位置: 首页>>代码示例>>C#>>正文


C# Tuple.Sum方法代码示例

本文整理汇总了C#中Tuple.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.Sum方法的具体用法?C# Tuple.Sum怎么用?C# Tuple.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tuple的用法示例。


在下文中一共展示了Tuple.Sum方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TableRenderer

 public TableRenderer(string title, Tuple<string, int>[] headers)
 {
     _title = title;
     _headers = headers;
     _totalWidth = _headers.Sum(h => h.Item2) + (_headers.Count() - 1) * 3;
     _rowTemplate = "| " + String.Join(" | ", _headers.Select((h, i) => "{" + i + ",-" + h.Item2 + "}").ToArray()) + " |";
 }
开发者ID:wurdum,项目名称:deployer,代码行数:7,代码来源:TableRenderer.cs

示例2: ShortSumOnTwoTuple

 public void ShortSumOnTwoTuple()
 {
     var sut = new Tuple<short, short>(1, 2);
       short expected = sut.AsEnumerable().Cast<short>().Sum();
       short actual = sut.Sum(x => (short) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleSumTests.Short.cs

示例3: DoubleSumOnTwoTuple

 public void DoubleSumOnTwoTuple()
 {
     var sut = new Tuple<double, double>(1, 2);
       double expected = sut.AsEnumerable().Cast<double>().Sum();
       double actual = sut.Sum(x => (double) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleSumTests.Double.cs

示例4: IntegerSumOnTwoTuple

 public void IntegerSumOnTwoTuple()
 {
     var sut = new Tuple<int, int>(1, 2);
       int expected = sut.AsEnumerable().Cast<int>().Sum();
       int actual = sut.Sum(x => (int) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleSumTests.Integer.cs

示例5: LongSumOnTwoTuple

 public void LongSumOnTwoTuple()
 {
     var sut = new Tuple<long, long>(1, 2);
       long expected = sut.AsEnumerable().Cast<long>().Sum();
       long actual = sut.Sum(x => (long) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleSumTests.Long.cs

示例6: DecimalSumOnTwoTuple

 public void DecimalSumOnTwoTuple()
 {
     var sut = new Tuple<decimal, decimal>(1, 2);
       decimal expected = sut.AsEnumerable().Cast<decimal>().Sum();
       decimal actual = sut.Sum(x => (decimal) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleSumTests.Decimal.cs

示例7: InsertGuids

        private int InsertGuids(Tuple<Position, int>[] selections)
        {
            var sumChanges = selections.Sum(x =>
            {
                scintilla.DeleteRange(x.Item1, x.Item2);
                scintilla.InsertText(x.Item1, Guid.NewGuid().ToString());

                return GuidHelperConstants.Regexlength - x.Item2;
            });
            return sumChanges;
        }
开发者ID:comcowo,项目名称:NppPluginGuidHelper,代码行数:11,代码来源:InsertGuid.cs

示例8: BuildMaxPerFlag

            /// <summary>
            /// This tacks on from-to percent
            /// </summary>
            private static Tuple<FlagColorCategory[], int, double, double>[] BuildMaxPerFlag(Tuple<FlagColorCategory[], int>[] groups)
            {
                double sumEnumValues = groups.Sum(o => o.Item1.Length);

                double sumPercent = 0;
                var retVal = new Tuple<FlagColorCategory[], int, double, double>[groups.Length];
                for (int cntr = 0; cntr < retVal.Length; cntr++)
                {
                    double percent = groups[cntr].Item1.Length / sumEnumValues;

                    retVal[cntr] = Tuple.Create(groups[cntr].Item1, groups[cntr].Item2, sumPercent, sumPercent + percent);

                    sumPercent += percent;
                }

                return retVal;
            }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:20,代码来源:Flag.cs

示例9: Avg

        public static double Avg(Tuple<double, double>[] weightedValues)
        {
            if (weightedValues == null || weightedValues.Length == 0)
            {
                return 0;
            }

            double totalWeight = weightedValues.Sum(o => o.Item2);
            if (Math1D.IsNearZero(totalWeight))
            {
                return weightedValues.Average(o => o.Item1);
            }

            double sum = weightedValues.Sum(o => o.Item1 * o.Item2);

            return sum / totalWeight;
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:17,代码来源:Math1D.cs


注:本文中的Tuple.Sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。