Range - Example
IEnumerable<int> ints = Enumerable.Range(1, 5);
foreach (var item in ints)
Console.WriteLine(item);
//Output
1
2
3
4
5
foreach (var item in ints)
Console.WriteLine(item);
//Output
1
2
3
4
5
Repeat - Example
IEnumerable<int> ints = Enumerable.Repea(7, 5);
foreach (var item in ints)
Console.WriteLine(item);
//Output
7
7
7
7
7
foreach (var item in ints)
Console.WriteLine(item);
//Output
7
7
7
7
7
Empty- Example
- The Empty operator generates an empty sequence of a specified type.
IEnumerable<string> strings= Enumerable.Empty<string>();
Console.WriteLine(strings.count());
//Output
0
Console.WriteLine(strings.count());
//Output
0
No comments:
Post a Comment