class MyCollection<T> : ICollection<T> { private class MyNode<T> { // snipped } } |
When compiled, this code generates a warning saying that T is confusing because used both for MyCollection and MyNode. In practice, the T will be same in both classes. What would you suggest as the correct design pattern for such a situation
Thanks in advance,
Joannes

Design pattern for internal node of a generic collection
doug2008
Simply omit type argument from MyNode.
Since it's nested type of MyCollection<T> it already know type T.
Read 20.1.12 Nested Types in generic classes for a reference.