Note that there are some explanatory texts on larger screens.

plurals
  1. POShould we use ICollection<T> in the Interface and Collection<T> in the class?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI would initialize it as something like `ICollection<Foo> bar = new List<Foo>(); ...` and then use `ICollection<Foo>` from there on (inside and outside of the class). Hopefully I understood the question correctly. Note that `ICollection<Foo>` might be too primitive for your needs and so an `IList<Foo>` would work better instead. This is something that I ended up doing once - switching from `ICollection` to `IList` since I needed to have the order as opposed to using something as general as a set.
      singulars
    2. COyes, you understood it correctly..just for the second part of my question: do you recommned ICollection<Foo> or to use ICollection<IFoo> ... the interface of Foo class
      singulars
    3. COTry to remain practical. If you do plan on changing the behavior of what implements `IFoo` and substitute a different thing, then yes, you do need an `IFoo` (and I hope that C# is smart enough to recognize the equivalence; I have not tried it). If you do not need to change the implementation of `Foo`, then there is probably not a good reason to create an `IFoo`. With `ICollection<Foo>` it makes more sense - you want to have the ability to use different data structures, say if you suddenly need better performance. You could substitute say dequee in place of List and still be good
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload