Home All Groups Group Topic Archive Search About

Emitting a Generic Type that has a Generic Base Class

Author
7 Jun 2006 1:25 PM
Patrick
Hey... I dont know if its possible but i'm trying to emit a class that would
look like this

The Base class commes from the code:

public class BaseClass<T>
{
// Whatever implementation...
}

I want to generate a child class that looks like this:

public class ChildClass<T> : BaseClass<T>
{
}

so i want to define ChildClass<> not ChildClass<int> or ChildClass<object>
....is it possible?

Author
7 Jun 2006 4:14 PM
Barry Kelly
Patrick <Patr***@discussions.microsoft.com> wrote:

> Hey... I dont know if its possible but i'm trying to emit a class that would
> look like this

By emit, do you mean System.Reflection.Emit, or do you simply mean
compiled C# code?

> The Base class commes from the code:
>
> public class BaseClass<T>
> {
> // Whatever implementation...
> }
>
> I want to generate a child class that looks like this:
>
> public class ChildClass<T> : BaseClass<T>
> {
> }

This descendant is perfectly possible and legal currently. It's the
standard pattern for deriving from Collection<T>, for example.

> so i want to define ChildClass<> not ChildClass<int> or ChildClass<object>
> ...is it possible?

What does 'ChildClass<>' mean?

-- Barry


AddThis Social Bookmark Button