本文整理汇总了C#中System.Collections.Generic.Zip方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Zip方法的具体用法?C# System.Collections.Generic.Zip怎么用?C# System.Collections.Generic.Zip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.Zip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRowTest
public void AddRowTest()
{
var percentWidths = new[] { 20, 30, 50 };
var controls = new[]
{
new InputBox(new XRect(0, 0, 10, 20), ""),
new InputBox(new XRect(0, 0, 10, 30), ""),
new InputBox(new XRect(0, 0, 10, 50), ""),
};
var rect = new XRect(0, 0, 100 + DefaultValues.Groupbox.MarginLeft + DefaultValues.Groupbox.MarginRight, 10);
var target = new GroupBox(rect);
target.AddRow(controls, percentWidths);
foreach (var control in controls.Zip(target.Controls, (i, o) => new { Input = i, Output = o }))
{
Assert.AreSame(control.Input, control.Output);
}
Assert.AreEqual(target.Controls.ElementAt(0).Rect.Left, 0);
Assert.AreEqual(target.Controls.ElementAt(1).Rect.Left, 20);
Assert.AreEqual(target.Controls.ElementAt(2).Rect.Left, 50);
Assert.AreEqual(target.Controls.ElementAt(0).Rect.Width, 20);
Assert.AreEqual(target.Controls.ElementAt(1).Rect.Width, 30);
Assert.AreEqual(target.Controls.ElementAt(2).Rect.Width, 50);
Assert.AreEqual(target.Rect.Height, target.MarginBottom + target.MarginTop + 50);
}
示例2: CanZipTwoSameLengthSequences
public void CanZipTwoSameLengthSequences()
{
var seq1 = new[] { 1, 2, 3 };
var seq2 = new[] { "um", "dois", "três" };
var seq3 = seq1.Zip(seq2, (x, y) => x + y).ToList();
seq3.Should().Have.SameSequenceAs("1um", "2dois", "3três");
}
示例3: CanZipThreeSequences
public void CanZipThreeSequences()
{
var seq1 = new[] { 1, 2, 3, 4 };
var seq2 = new[] { 1, 2 };
var seq3 = new[] { "um", "dois", "três" };
var seq4 = seq1.Zip(seq2, (x, y) => x * y).Zip(seq3, (x, y) => x + y).ToList();
seq4.Should().Have.SameSequenceAs("1um", "4dois");
}