Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are the good reasons to wish that .NET generics could inherit one of the generic parameter types?
    primarykey
    data
    text
    <p>This post is in continuation of <a href="https://stackoverflow.com/questions/1842636/why-cannot-c-generics-derive-from-one-of-the-generic-type-parameters-like-they-c">this one</a>.</p> <p>I am trying to understand if I am the only one who misses and needs the ability of a .NET generic type to inherit one of its generic parameter types.</p> <p>The challenge is to collect compelling reasons in favour of this feature or, alternatively, get to know that there are none.</p> <p>I give my reason to have it as an answer to this question - see below.</p> <p>I am asking folks out there to add theirs as answers to this post.</p> <p>If you disagree that the feature is useful or have no good reasons in favour - please refrain from posting anything here, though you can do so in the original post that has started it all - <a href="https://stackoverflow.com/questions/1842636/why-cannot-c-generics-derive-from-one-of-the-generic-type-parameters-like-they-c">here</a>.</p> <p><strong>P.S.</strong></p> <p>Some C++ patterns are irrelevant in .NET. For instance, in his excellent book <a href="http://rads.stackoverflow.com/amzn/click/0201704315" rel="nofollow noreferrer">Modern C++ Design</a> Andrei Alexandrescu describes how to create a list of types evaluated at the compile time. Naturally, this pattern is irrelevant for .NET, where if I need a list of types I just create <code>List&lt;Type&gt;</code> and populate it with types. So, let us try to come up with reasons pertinent to the .NET framework and not just blindly translating C++ coding techniques to C#.</p> <p><strong>P.P.S.</strong></p> <p>Of course, this discussion is strictly academic. Even if a hundred compelling reasons for the feature in question is surfaced it is not going to be implemented, ever.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload