本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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()) + " |";
}
示例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);
}
示例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);
}
示例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);
}
示例10: CountOnOneTuple
public void CountOnOneTuple()
{
const int expected = 1;
var t = new Tuple<int>(-1);
int actual = t.Count();
Assert.AreEqual(expected, actual);
}
示例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);
}
示例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));
}
}
示例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;
}