From: CSharpner on
I was expecting the following code to work in C# 4.0:

public class MyGenericType<T>: T
{
//... stuff ...
}

But it doesn't.

Perhaps the syntax is different than what I'm attempting? Or is it
just that it still hasn't been implemented and maybe in C# 5.0?

http://books.google.com/books?id=kQTeadi7388C&pg=PA151&lpg=PA151&dq=%22cannot+derive+from+t+because+it+is+a+type+parameter%22&source=web&ots=8gMDRNdnWc&sig=FxdQ7oKM8iF67TYozJ1Hbm-CVqM#v=onepage&q=%22cannot%20derive%20from%20t%20because%20it%20is%20a%20type%20parameter%22&f=false
From: Arne Vajhøj on
On 14-05-2010 20:49, CSharpner wrote:
> I was expecting the following code to work in C# 4.0:
>
> public class MyGenericType<T>: T
> {
> //... stuff ...
> }
>
> But it doesn't.
>
> Perhaps the syntax is different than what I'm attempting? Or is it
> just that it still hasn't been implemented and maybe in C# 5.0?
>
> http://books.google.com/books?id=kQTeadi7388C&pg=PA151&lpg=PA151&dq=%22cannot+derive+from+t+because+it+is+a+type+parameter%22&source=web&ots=8gMDRNdnWc&sig=FxdQ7oKM8iF67TYozJ1Hbm-CVqM#v=onepage&q=%22cannot%20derive%20from%20t%20because%20it%20is%20a%20type%20parameter%22&f=false

I don't think you can do that.

There is a huge practical problem. Generic classes in C#
get compiled as they are (unlike C++ templates that
get compiled when they get used). It could be very
difficult to compile something inheriting from something unknown.

Arne
From: CSharpner on
On May 14, 9:29 pm, Arne Vajhøj <a...(a)vajhoej.dk> wrote:
> On 14-05-2010 20:49, CSharpner wrote:
>
> > I was expecting the following code to work in C# 4.0:
>
> >      public class MyGenericType<T>: T
> >      {
> >          //... stuff ...
> >      }
>
> > But it doesn't.
>
> > Perhaps the syntax is different than what I'm attempting?  Or is it
> > just that it still hasn't been implemented and maybe in C# 5.0?
>
> >http://books.google.com/books?id=kQTeadi7388C&pg=PA151&lpg=PA151&dq=%...
>
> I don't think you can do that.
>
> There is a huge practical problem. Generic classes in C#
> get compiled as they are (unlike C++ templates that
> get compiled when they get used). It could be very
> difficult to compile something inheriting from something unknown.
>
> Arne

If they didn't implement it on usage, then yes, it would be difficult,
if not impossible, BUT, there's nothing preventing them from
implementing it a different way... They could generate it based on
usage. So, the story line is that they will eventually implement it,
so I was just checking to see if anyone knows if it's actually been
implemented yet. If you don't know, that's OK.
From: Arne Vajhøj on
On 15-05-2010 17:38, CSharpner wrote:
> On May 14, 9:29 pm, Arne Vajh�j<a...(a)vajhoej.dk> wrote:
>> On 14-05-2010 20:49, CSharpner wrote:
>>
>>> I was expecting the following code to work in C# 4.0:
>>
>>> public class MyGenericType<T>: T
>>> {
>>> //... stuff ...
>>> }
>>
>>> But it doesn't.
>>
>>> Perhaps the syntax is different than what I'm attempting? Or is it
>>> just that it still hasn't been implemented and maybe in C# 5.0?
>>
>>> http://books.google.com/books?id=kQTeadi7388C&pg=PA151&lpg=PA151&dq=%...
>>
>> I don't think you can do that.
>>
>> There is a huge practical problem. Generic classes in C#
>> get compiled as they are (unlike C++ templates that
>> get compiled when they get used). It could be very
>> difficult to compile something inheriting from something unknown.
>
> If they didn't implement it on usage, then yes, it would be difficult,
> if not impossible, BUT, there's nothing preventing them from
> implementing it a different way... They could generate it based on
> usage. So, the story line is that they will eventually implement it,
> so I was just checking to see if anyone knows if it's actually been
> implemented yet. If you don't know, that's OK.

C#/.NET generic classes get compiled as other classes.

Arne
From: Patrice on
Hello,

Your best bet could be to explain what you are trying to do...

See perhaps if :
http://www.eggheadcafe.com/software/aspnet/31868047/-inherit-from-generic.aspx
could be a possible workaround for you...

--
Patrice