'C# DataGridViewSelectedCellCollection can't implicitly cast to IList
Observations:
DataGridViewSelectedCellCollectionimplementsIList,ICollection, andIEnumerable.DataGridViewSelectedCellCollectiondoes not have all the functions in its API to implement all of these interfaces (e.g. it's missingIList.Add
Question:
- How can
DataGridViewSelectedCellCollectionnot implement all the functions in the interface? - Why can't the compiler implicitly cast to the interface (or at least provide details in the compiler message that there's ambiguity)?
Example:
Where selected is DataGridViewSelectedCellCollection and cell is DataGridViewCell
This doesn't compile: selected.Add(cell);
But this does: ((IList)selected).Add(cell);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
