(In a C# program) I have a List<Author> authors
, where Author
is a class I wrote. Lists
have a default Add(Object o)
method, but I need to make it either less accessible or overwrite it for specifically my authors
object.
So far, I've found information on polymorphism, extension methods (like this one), and delegates in combination with dynamic objects, but I'm not sure if what I'm asking is possible in the first place without keeping things simple and creating a new class that inherits from List<Author>
(I figure that even that doesn't make sense, given that I would only use the class once).
Note that unlike this scenario, I don't have access to the List<T>
class, so I can't make the method virtual or partial, or create an overflow that hides the original method.
Given the situation, how would I make the existing Add(Object o)
method private and overwrite it with a public method? Is the best solution the separate class, or something more complicated?