本文整理汇总了C#中System.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# System.Skip方法的具体用法?C# System.Skip怎么用?C# System.Skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main () {
var ints = new[] { 1, 2, 3, 4 };
Console.WriteLine(ints.Last());
Console.WriteLine(ints.Last((i) => i < 3));
// Test the non-IList path
Console.WriteLine(ints.Skip(1).Last());
Console.WriteLine(ints.Skip(1).Last((i) => i < 3));
}
示例2: EmptySequenceIsReturnedWhenSourceContainsFewerThanCountElements
public void EmptySequenceIsReturnedWhenSourceContainsFewerThanCountElements()
{
var source = new[] { 1 };
var result = source.Skip(2);
Assert.That(result, Is.EqualTo(Enumerable.Empty<Int32>()));
}
示例3: AdjacentElements
public void AdjacentElements()
{
IEnumerableWithCount<string> elements = new[] { "a", "b", "c", "d", "e" }.AsEnumerableWithCount();
IEnumerableWithCount<string> query = elements.Zip(elements.Skip(1), (x, y) => x + y);
Assert.AreEqual(4, query.Count);
query.AssertSequenceEqual("ab", "bc", "cd", "de");
}
示例4: E_SlicingArrays
public void E_SlicingArrays()
{
var array = new[] { "peanut", "butter", "and", "jelly" };
Assert.AreEqual(new string[] { (string)FILL_ME_IN, (string)FILL_ME_IN }, array.Take(2).ToArray());
Assert.AreEqual(new string[] { (string)FILL_ME_IN, (string)FILL_ME_IN }, array.Skip(1).Take(2).ToArray());
}
示例5: Main
public static void Main () {
var ints = new[] { 1, 2, 3, 4 };
foreach (var i in ints.Skip(2))
Console.WriteLine(i);
}
示例6: ReadSubItems
private void ReadSubItems(System.Xml.XmlReader reader, ArrayList result, bool securityTrimmingEnabled)
{
int depth = reader.Depth + 1;
while (reader.Read())
{
if (reader.Depth == depth)
{
if (reader.NodeType == System.Xml.XmlNodeType.Element)
{
var aResult = ReadResult(reader, securityTrimmingEnabled);
if (aResult != null)
result.Add(aResult);
}
else if (reader.NodeType == XmlNodeType.EndElement)
{
}
}
else if (reader.Depth > depth)
{
reader.Skip();
}
else if (reader.Depth < depth)
{
break;
}
}
}
示例7: while
void IFlickrParsable.Load(System.Xml.XmlReader reader)
{
reader.Read();
while (reader.LocalName != "auth")
{
switch (reader.LocalName)
{
case "token":
Token = reader.ReadElementContentAsString();
break;
case "perms":
Permissions = (AuthLevel)Enum.Parse(typeof(AuthLevel), reader.ReadElementContentAsString(), true);
break;
case "user":
User = new FoundUser();
((IFlickrParsable)User).Load(reader);
break;
default:
UtilityMethods.CheckParsingException(reader);
reader.Skip();
break;
}
}
}
示例8: Load
void IFlickrParsable.Load(System.Xml.XmlReader reader)
{
Load(reader, false);
if (reader.LocalName != "stats")
{
UtilityMethods.CheckParsingException(reader);
}
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "views":
StatViews = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
case "comments":
StatComments = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
case "favorites":
StatFavorites = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
if (reader.LocalName == "description")
Description = reader.ReadElementContentAsString();
reader.Skip();
}
示例9: ReadFromStreamWithDefaultColumnsShouldHandleFirstRowAsRowData
public void ReadFromStreamWithDefaultColumnsShouldHandleFirstRowAsRowData()
{
DataTableBuilder builder = new DataTableBuilder();
var stream = new MemoryStream();
var sw = new StreamWriter(stream);
var rows = new[] { "first,row,is,data", "second,row,is,johnny", "second,row,was,laura", };
foreach (var row in rows)
{
sw.WriteLine(row);
}
sw.Flush();
stream.Seek(0, SeekOrigin.Begin);
try
{
var lazy = builder.ReadLazy(stream, rows[0].Split(','));
Assert.Equal(rows[0].Split(','), lazy.ColumnNames);
var rowEnumerator = rows.Skip(0).GetEnumerator();
rowEnumerator.MoveNext();
var rowCount = 0;
foreach (var row in lazy.Rows)
{
Assert.Equal(rowEnumerator.Current, string.Join(",", row.Values));
rowEnumerator.MoveNext();
rowCount++;
}
Assert.Equal(rows.Length, rowCount);
}
finally
{
sw.Dispose();
stream.Dispose();
}
}
示例10: while
void IFlickrParsable.Load(System.Xml.XmlReader reader)
{
if (reader.LocalName != "referrer")
UtilityMethods.CheckParsingException(reader);
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "url":
Url = reader.Value;
break;
case "searchterm":
SearchTerm = reader.Value;
break;
case "views":
Views = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Skip();
}
示例11: while
void IFlickrParsable.Load(System.Xml.XmlReader reader)
{
if (reader.LocalName != "stats")
{
UtilityMethods.CheckParsingException(reader);
}
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "views":
Views = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
case "comments":
Comments = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
case "favorites":
Favorites = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Skip();
}
示例12: while
void IFlickrParsable.Load(System.Xml.XmlReader reader)
{
if (reader.LocalName != "place_type")
UtilityMethods.CheckParsingException(reader);
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "place_type_id":
case "id":
Id = reader.ReadContentAsInt();
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
Name = reader.ReadContentAsString();
reader.Skip();
}
示例13: Skip_SkipsItems
public void Skip_SkipsItems()
{
var orderedQueryable = new[] { "1", "3", "6", "2", "8" }.AsQueryable().OrderBy(i => i);
var orderedSource = new OrderedSource<string>(orderedQueryable);
var expected = orderedQueryable.Skip(2).ToList();
var actual = orderedSource.Skip(2).ToList();
CollectionAssert.AreEquivalent(expected, actual);
}
示例14: AllElementsOfSourceAreYieldedWhenCountIsLessThanOrEqualToZero
public void AllElementsOfSourceAreYieldedWhenCountIsLessThanOrEqualToZero()
{
var source = new[] { 1 };
var result = source.Skip(0);
var expected = new[] { 1 };
Assert.That(result, Is.EqualTo(expected));
}
示例15: ElementsBeforeCountAreSkipped
public void ElementsBeforeCountAreSkipped()
{
var source = new[] { 1, 2, 3, 4, 5 };
var result = source.Skip(3);
var expected = new[] { 4, 5 };
Assert.That(result, Is.EqualTo(expected));
}