C#: IEnumerable, GetEnumerator, a simple, simple example please!

Posted by Andrew White on Stack Overflow See other posts from Stack Overflow or by Andrew White
Published on 2010-05-18T19:36:32Z Indexed on 2010/05/18 19:50 UTC
Read the original article Hit count: 984

Filed under:
|
|
|

Hi there,

Trying to create an uebersimple class that implements get enumerator, but failing madly due to lack of simple / non-functioning examples out there. All I want to do is create a wrapper around a data structure (in this case a list, but I might need a dictionary later) and add some functions.

public class Album
{
    public readonly string Artist;
    public readonly string Title;
    public Album(string artist, string title)
    {
         Artist = artist;
         Title = title;
    } 
}
public class AlbumList
{
    private List<Album> Albums = new List<Album>;
    public Count { get { return Albums.Count; } }

    .....
    //Somehow GetEnumerator here to return Album
}

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about list