What is Ienumerable



What is Ienumerable..

Answer / 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

More Dot Net AllOther Interview Questions

What re interop services?

0 Answers  


What is serialization, how it works in .NET?

1 Answers  


deference between display and visibility property of CSS

0 Answers   PCS, Prithvi,


Explain How to improve the cache performance? : Dot net architecture

0 Answers  


readonly syntax ?

0 Answers  






how u maintain data while navigating one page to another?

2 Answers  


which of the following statement is true about gac. a)it is being handled by .net framwork b)It is special folder c)it can have files with same name etc etc.

4 Answers   Honeywell,


when garbage collector come into picture. ?

2 Answers  


What are bindings?

0 Answers  


how to minimize,maximize and restore my form programmatically?

1 Answers   Interlac, Six Sigma,


What is a virtual memory? : Dot net architecture

0 Answers  


When do I need to use gc.keepalive?

0 Answers  


Categories