Using generics in a business object and collection
<p>I have a base object abstract class and a base object collection class for some business objects to inherit from. I'm trying to figure out how to pass the base object type to the collection class (and other methods). I've been able to solve this by wrapping the class in an interface but i'm wondering if there is another way to do this or if using an interface is the best way. i think my question might make more sense from the code below.</p>

<p>i have a base class define - </p>

<pre><code>public abstract class BaseObject&lt;TYPE,KEY&gt;:where TYPE:BaseObject&lt;TYPE,KEY&gt;, new()

public KEY ObjectId {get;protected set; }
</code></pre>

<p>i have a class that inherits from BaseObject</p>

<pre><code>public class Customer : BaseObject&lt;Customer,Guid&gt;
</code></pre>

<p>My base collection class is -</p>

<pre><code>public abstract class BaseObjectCollection&lt;T&gt; : List&lt;T&gt; where T: BaseObject, new()
</code></pre>

<p>I also have a few methods in other class that want to reference this baseclass -</p>

<pre><code>public bool ValidateRule(BaseObject dataObject) {etc...}
</code></pre>
