是否有实现集合和选定值的类型或接口?

bsh*_*52s 0 c# collections

我需要一个类型来跟踪集合和集合中的选定值,类似于列表框的作用.是否有现有的(非gui控制)集合?我知道这很简单,但如果有的话,我宁愿使用微软提供的类型.

基本上,这就是我想要的:

interface ISelectionList<T>
{
   T Selected
   {
      get;
      set;
   }
   IList<T> Values
   {
   }
}
Run Code Online (Sandbox Code Playgroud)

And*_*are 5

不,.NET框架中没有类似的东西.

我想建议你以不同的方式构建你的接口,以利用继承接口的强大功能.

尝试这样的事情:

interface ISelectionList<T> : IList<T>
{
    T Selected { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

这将允许您仍然使用您ISelectionList<T>IList<T>需要.