I have a class, let's say Player
, with a name and some attributes:
public class Players
{
public string PlayerName { get; set; }
public IList<Goal> Goals { get; set; }
...
}
I want to create a custom collection class, PlayerCollection
, but using a Dictionary instead of a list for quicker search. So:
public class PlayersCollection
{
private readonly IDIctionary<string, Player> _players;
....
Using a dictionary with the player name as the key will make things easier in the rest of my program.
Now I'd like to implement IEnumerable<Player>
, in order to iterate over the player class, but I can't use the dictionary's enumerator, because it is implemented on KeyValuePair<string, Player>
.
How can I do that?