Questions tagged [icollection]

The ICollection interface is the base interface for classes in the System.Collections namespace. It defines size, enumerators, and synchronization methods for all non-generic collections

The ICollection interface is the base interface for classes in the System.Collections namespace.

The ICollection interface extends IEnumerable; IDictionary and IList are more specialized interfaces that extend ICollection. An IDictionary implementation is a collection of key/value pairs, like the Hashtable class. An IList implementation is a collection of values and its members can be accessed by index, like the ArrayList class.

Some collections that limit access to their elements, such as the Queue class and the Stack class, directly implement the ICollection interface.

If neither the IDictionary interface nor the IList interface meet the requirements of the required collection, derive the new collection class from the ICollection interface instead for more flexibility.

279 questions
-1
votes
1 answer

ICollection ClearAndAddRange share reference?

I have two ICollection lists fullList and displayList. private void method() { if(condition != null) { displayList.Clear(); if(fullList.Count() > 0) { displayList.ClearAndAddRange( …
SuicideSheep
  • 5,260
  • 19
  • 64
  • 117
-1
votes
1 answer

How to add entity that contains itself to ICollection MVC

There is a post that says how to do this but it does not explain how to work with it. We have a class "Persoon" (dutch) in English 'Person' and we want to add a friend (vriend in Dutch) with an ICollection who's also a 'Person' We have the…
Dolly93
  • 46
  • 5
-2
votes
1 answer

Having trouble with an ICollection/IEnumerable operation - won't remove an occurrence

I'm using a FastObjectListView to enter S/Ns of units to a Disposition (sold, RMA, etc) and I enter a constant for the first S/N - "(Enter Serial)" I'm using this same model in another section of code (RMA) but I'm missing something when trying to…
BigBear2k
  • 19
  • 4
-2
votes
1 answer

I need help understanding how C# uses Virtual and also how ICollection is used when Virtual is applied

I researched the Key Word Virtual and found that it allows an object's method to be overwritten. I also looked at ICollection and learned of the two options to implement it. So, if I saw someone create an Object say: public class Lecture: and I had…
Serious
  • 153
  • 11
-2
votes
2 answers

The property Count from ICollection is still around for backward compatibility?

Previous Context To understand what I'm questioning, see first the question "Why does .Count work without parentheses?" In that question is discussed, Why exists Count (property) and Count() (method) in classes that implements ICollection. that…
Jonny Piazzi
  • 3,684
  • 4
  • 34
  • 81
-3
votes
3 answers

Why do I need to .Include() collections

I wrote a query which is pretty simple: var locations = await _context.Locations .Include(x => x.LocationsOfTheUsers) .Include(x => x.Address) .ThenInclude(x => x.County) …
Roxy'Pro
  • 4,216
  • 9
  • 40
  • 102
-3
votes
2 answers

Why after filling my custom collection, is there a loop in ICollection.Count

I've never done a collection before. I tried to find Solutions on the internet and also with what they had to add for the interfaces to work. I added everything I could find on the web. public class RecipeObjectCollection :…
BigRimbus
  • 1
  • 2
-3
votes
2 answers

Extension method on ICollection doesn't change the calling list?

I want to create an extension method that runs on a List and accept another list: public static void Charge(this ICollection targetList, ICollection sourceList) where T : class, new() { if (targetList == null ||…
mshwf
  • 7,009
  • 12
  • 59
  • 133
-5
votes
1 answer

Access a value inside ICollection

string greeting = ""; foreach (System.Collections.Generic.ICollection x in greetingRecommendation.Resolution.Values) { foreach (var y in x) { greeting = (string)y; } } I need to…
1 2 3
18
19