Search code examples
c#.netdebuggingicollection

Why is IsReadOnly listed as a non-public member?


I'm looking at an instance of ICollection called pxe in the VS Watch window. I understand that the Raw View is meant to show the object without anything extra added. The property IsReadOnly is a member of the ICollection interface and is public by default. Why is it listed in the Non-public members in the Watch window?

enter image description here


Solution

  • ReadonlyCollection<T> implements both IList and ICollection<T> and both interfaces contains IsReadOnly property. ReadonlyCollection<T> implements this property explicitly, so you cannot access it without casting ReadonlyCollection<T> to IList or ICollection<T>, and so visual studio treat it as non-public member