If I have a method that requires a parameter that,
Count
propertyWhat should the type
You are out of luck here. IList
doesn't implement IReadOnlyList
. List
does implement both interfaces, but I think that's not what you want.
However, you can use LINQ:
Count()
extension method internally checks whether the instance in fact is a collection and then uses the Count
property.ElementAt()
extension method internally checks whether the instance in fact is a list and than uses the indexer.