tags:

views:

34

answers:

1

I need a type that keeps track of a collection and the selected value in a collection, similar to what a list box would do. Is there an existing (non-gui control) collection for this? I know it's fairly simple but I would rather use Microsoft's provided type if there is one.

Basically, this is what I want:

interface ISelectionList<T>
{
   T Selected
   {
      get;
      set;
   }
   IList<T> Values
   {
   }
}
+5  A: 

No, there is nothing like that in the .NET framework.

I would like to suggest that you build your interface a bit differently to leverage the power of inherited interfaces.

Try something like this:

interface ISelectionList<T> : IList<T>
{
    T Selected { get; set; }
}

This will allow you to still use your ISelectionList<T> as an IList<T> where needed.

Andrew Hare
Dammit, you beat me to it! ;-) +1
DoctaJonez