views:

150

answers:

2

Hi,

I have IEnumerable which contains number Data inside it.

Edit The IEnumerable is from System.Collection.Ienumerable directive.

Attached the snapShot of Viual Studio, Enum that Contains Data:

alt text

Just to brief about the above image, eLevelData is the IEnumerable variable, in which I have my data .

Now I want to go to the data at index 4 or 5, but I don't want to use foreach loop. Any suggestions please.

Thanks,

Subhen

+3  A: 

Don't know much about what subset of .NET BCL/LINQ is available in Silverlight, but Skip should do the trick. But generally speaking it still uses foreach internally:

var item = eLevelData.Skip(4 /* or 5 */).First();
Anton Gogolev
+7  A: 

var item = eLevelData.ElementAt(index);

If your collection is typed as IEnumerable instead of IEnumerable<T> you'll need to use the Cast extension method before you can call ElementAt e.g.

var item = eLevelData.Cast<RMSRequestProcessor.RMSMedia>().ElementAt(index)

Lee
Hi Lee,I am not getting ElementAt() method. I am using this in Silverlight
Subhen
@Subhen - Do you have a `using System.Linq` directive at the top of the page? It works in Silverlight 3 for me.
Lee