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


C# Tuple.Count方法代码示例

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


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

示例1: DoubleCountOnTwoTuple

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

示例2: LongCountOnTwoTuple

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

示例3: AsString

 public static string AsString(Tuple<string, object>[] keyValues)
 {
     return keyValues.Count() == 1
         ? keyValues.First().Item2 as string
         : keyValues.Select(k => string.Format("{0}='{1}'", k.Item1, k.Item2))
             .Aggregate((c, n) => c + "," + n);
 }
开发者ID:iambmelt,项目名称:Vipr,代码行数:7,代码来源:ODataKeyPredicate.cs

示例4: DecimalCountOnThreeTuple

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

示例5: ShortCountOnTwoTuple

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

示例6: 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

示例7: CountOnTwoTuple

 public void CountOnTwoTuple()
 {
     const int expected = 2;
       var t = new Tuple<int, int>(-1, -2);
       int actual = t.Count();
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleLengthTests.cs

示例8: IntegerCountOnTwoTuple

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

示例9: CountOnSixTuple

 public void CountOnSixTuple()
 {
     const int expected = 6;
       var t = new Tuple<int, int, int, int, int, int>(-1, -2, -3, -4, -5, -6);
       int actual = t.Count();
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleLengthTests.cs

示例10: CountOnOneTuple

 public void CountOnOneTuple()
 {
     const int expected = 1;
       var t = new Tuple<int>(-1);
       int actual = t.Count();
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleLengthTests.cs

示例11: CountOnFourTuple

 public void CountOnFourTuple()
 {
     const int expected = 4;
       var t = new Tuple<int, int, int, int>(-1, -2, -3, -4);
       int actual = t.Count();
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleLengthTests.cs

示例12: VerifyResults

        internal static void VerifyResults(Tuple<string, string>[] expectedResults, IEnumerable<DbValidationError> actualResults)
        {
            Assert.Equal(expectedResults.Count(), actualResults.Count());

            foreach (var validationError in actualResults)
            {
                Assert.True(
                    expectedResults.SingleOrDefault(
                        r => r.Item1 == validationError.PropertyName && r.Item2 == validationError.ErrorMessage) != null,
                    String.Format(
                        "Unexpected error message '{0}' for property '{1}' not found", validationError.ErrorMessage,
                        validationError.PropertyName));
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:ValidationErrorHelper.cs

示例13: MergeAndCount

        private Tuple[] MergeAndCount(Tuple[] tuples, int[] ans, int start, int end)
        {
            if (start >= end)
            {
                return new Tuple[] { tuples[start] };
            }

            Tuple[] subTuple = new Tuple[end - start + 1];

            int m = start + (end - start) / 2;

            Tuple[] lefTuples = MergeAndCount(tuples, ans, start, m);
            Tuple[] rightTuples = MergeAndCount(tuples, ans, m + 1, end);

            int l = 0, r = 0;
            for (int i = 0; i <= end - start; i++)
            {
                if (r >= rightTuples.Count())
                {
                    subTuple[i] = lefTuples[l++];
                    continue;
                }

                if (l >= lefTuples.Count())
                {
                    subTuple[i] = rightTuples[r++];
                    continue;
                }

                if (r < rightTuples.Count() && lefTuples[l].Value > rightTuples[r].Value)
                {
                    subTuple[i] = rightTuples[r];
                    int t = l;
                    while (t < lefTuples.Count())
                    {
                        ans[lefTuples[t++].Index]++;
                    }
                    r++;
                }
                else if (l < lefTuples.Count())
                {
                    subTuple[i] = lefTuples[l++];
                }
            }

            for (int i = 0; i < subTuple.Count(); i++)
            {
                tuples[start++] = subTuple[i];
            }

            return subTuple;
        }
开发者ID:husthk986,项目名称:BlackSwan,代码行数:52,代码来源:CountSmallerNumbers.cs


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