I do not think the point of limitation (but I could be wrong).
As I understand it, restrictions do not have much to do with inheritance as such. What you are really doing is a type restriction that can be used if you use (instantiate) a class with type arguments.
Classes with type arguments are similar to Mad-Libs, and the restrictions are similar to the instructions that appear under spaces:
"Bob loves ______ with friends every night." (what is madlib)
"Bob loves every night (with a verb) ___ with his friends" (maslib with instructions).
Check this:
public class MadLib<W> {
public void addWord(W word) {
System.Console.WriteLine("bob likes to " + word + " with his friends");
}
}
public class MadLib<W> where W:Verb{
public void addWord(W word) {
System.Console.WriteLine("bob likes to " + word + " with his friends");
}
}
source
share