What is Ienumerable

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


Please Help Members By Posting Answers For Below Questions

how to use custom field validation

2135


how can we achieve language interoperability through CLS? How MSIL works?

700


Define the mesi? : Dot net architecture

616


Explain the types of memory management? : .NET Architecture

594


How can implement drag and drop using atlas?

643






can u give me real example of how web.config overrides the machine.config file?

1370


What is parallel computing?

622


What is the purpose of hard disk? : Dot net architecture

599


Waht is Dot net Arcitecture

2038


Describe the advantages of writing a managed code application instead of unmanaged one. What is involved in certain piece of code being managed?

706


What are the options provived by vss to the user? how it will help us while delevoping application?

1865


Explain the race around condition? : Dot net architecture

558


How cache is used? : Dot net architecture

583


What is a clickonce application?

592


Can I create my own context attributes?

644