Take
In this chapter you will learn:
Get to know Take operator
Take emits the first n elements and discards the rest;
using System;/*from ja v a2 s . c om*/
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
string[] names = { "Java", "C#", "Javascript", "SQL",
"Oracle", "Python", "C++", "C", "HTML", "CSS" };
IEnumerable<string> query = names.Take(2);
foreach (string s in query)
{
Console.WriteLine(s);
}
}
}
Next chapter...
What you will learn in the next chapter:
- How to use TakeWhile operator
- TakeWhile with filter delegate
- Filter string array
- SkipWhile then TakeWhile
- TakeWhile by index
Home » C# Tutorial » Linq Operators