You're trying to cast from a untyped to a typed enumeration... it just don't
go... I would just write a util class, how about this?

public class StrongEnumerator<T> : IEnumerable<T>
{
    private IEnumerable _source;

    public StrongEnumerator(IEnumerable source)
    {
        _source = source;
    }

    public IEnumerator<T> GetEnumerator()
    {
        foreach (T t in _source) yield return t;
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return _source.GetEnumerator();
    }
}

Then you could do something like, List<RepeaterItem> items = new
List<RepeaterItem>(new
StrongEnumerator<RepeaterItem>(_reservesRepeater.Items));

Without looking at the IL I might wonder just how efficient using a foreach
and yield is, but at least it's easy to read ;o)

Chez,

 - Alex

> -----Original Message-----
> From: Discussion of advanced .NET topics. [mailto:ADVANCED-
> [EMAIL PROTECTED] On Behalf Of Paul Cowan
> Sent: Thursday, 21 September 2006 8:53 p.m.
> To: [email protected]
> Subject: [ADVANCED-DOTNET] Convert RepeaterItemCollection to
> List<RepeaterItem>
>
> Hi,
>
> Is there anyway I can convert a RepeaterItemCollection to a generic
> List<RepeaterItem> in one line of code, I have tried the following:
>
> List<RepeaterItem> items = new
> List<RepeaterItem>((IEnumerable<RepeaterItem>)_reservesRepeater.Items);
>
> Which just does not compile for obvious reasons, also as a side note, has
> everyone come across predicates in .NET 2.0:
>
> http://blogs.msdn.com/devdev/archive/2006/06/30/652802.aspx
>
> This is very cool.
> Paul
>
>
>
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to