79331425

Date: 2025-01-05 19:46:48
Score: 0.5
Natty:
Report link

You can't cast List<Child> to List<Parent> directly, but you can cast List<Child> to IReadOnlyList<Parent>. Ex:

List<Child> childList = new List<Child>();
...
IReadOnlyList<Parent> parentList = childList;

This works because List<T> extends IReadOnlyList<out T>. Note T is covariant in the IReadOnlyList<out T> interface.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: star4z