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
Explain dma? : Dot net architecture
Explain domestic architecture artifacts? : .NET Architecture
How does .net remoting work?
What is .net viewstate?
how we can fire event in databound column in datagrid without using button?
How is the using() pattern useful? What is idisposable?
Explain is development of a mobile web application with asp.net is very easy? : Microsoft dot net mobile
Explain Intermediate Language?
what are constructors and destructors?
What is the purpose of cache? How is it used? : Dot net architecture
Explain the difference between primary & secondary storage device? : Dot net architecture
What is a service contract, operation contract and data contract?
What is an asssembly qualified name? Is it a filename? How is it different?
Explain the difference between state server and sqlserver : Dot net architecture
What is the .net class that allows the retrieval of a data element using a unique key?