Design pattern for internal node of a generic collection

I am currently design a complicated generic collection with .Net 2.0. Basically I have the following design:


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


Answer this question

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.

     

     


  • Design pattern for internal node of a generic collection