Answer Posted / wasim akhtar
The IEnumerable interface appears throughout C# programs. It specifies that the underlying type implements the GetEnumerator method. It enables the foreach-loop to be used.
Program that uses IEnumerable<T> [C#]
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
IEnumerable<int> result = from value in Enumerable.Range(0, 2)
select value;
// Loop.
foreach (int value in result)
{
Console.WriteLine(value);
}
// We can use extension methods on IEnumerable<int>
double average = result.Average();
// Extension methods can convert IEnumerable<int>
List<int> list = result.ToList();
int[] array = result.ToArray();
}
}
Output
0
1
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to implement the display in the class printdoc (how to resolve the naming conflict) a: no naming conflicts
Explain dotnet framework ?
Explain pipelining? : Dot net architecture
what is the method while we are using adapter and dataset ?
Explain how does .net mobile work? : Microsoft dot net mobile
what are login controls?
How do I know when my thread pool work item has completed?
Use of Enable view state ? if turn off what happen ?
What is .net mobile automatic paging? : Microsoft dot net mobile
What is one way operation?
What is a service class?
What re interop services?
So what exactly is the configuration file for then?
What other than biginteger has been introduced in system.numerics namespace?
What is the use of web.config?