Re: Feature request for C# Generic inheritence
- From: "Ido Samuelson" <ido.samuelson@xxxxxxxxx>
- Date: Thu, 27 Sep 2007 05:28:22 +0200
This is correct. I thought that for generic inheritance, the compiler will create an explicit type at compile time. Same way anonymous method works.
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message news:#oRPonIAIHA.1168@xxxxxxxxxxxxxxxxxxxxxxx
The trouble is that .NET generics, unlike C++ templates, are completely compiled in generic form. However, all base classes must be known at compile time. Only C++ templates, which are made concrete before being compiled, can inherit from template parameters. However .NET classes can use the curiously recurring template pattern which has some overlapping applications..
"Ido Samuelson" <isamuelson@xxxxxxxxxx> wrote in message news:4CDD1C70-E791-4D63-977E-A170CDE8D098@xxxxxxxxxxxxxxxx
Hello,
What do you think about the following features:
public class GenericDecorator<T> : T
{
}
can leverage to a few things:
public interface IChannel
{
void Connect();
void Disconnect();
}
public class TcpChannel : IChannel
{
...
}
public class ChannelDescriber<T> : T where T : IChannel, class
{
public string ChannelName {get; set;}
}
another more complicated example:
public class Extender<T,K> : T
{
public K Data {get;set;}
}
which can be use to :
Extender<EventArgs,string> extender;
extender.Data (give the same ability as EventArgs<T> but more generic which can leverage other types that do not support generics.
Last is for delegates aka
delegate void extendDelegate<T,K>(K t) : T where T : delegate
// K should be added as first parameter.
and usage:
extendDelegate<ThreadStart,string> Start;
Start("hello world");
which means that even further we can do this:
System.Threading.Thread.Start(Start("ido",null)); // anonymous delegates feature
void Start(string name, object state);
you can vote for the feature in the following like:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299676&wa=wsignin1.0
--
Best,
Ido Samuelson
- Follow-Ups:
- Re: Feature request for C# Generic inheritence
- From: Ben Voigt [C++ MVP]
- Re: Feature request for C# Generic inheritence
- References:
- Feature request for C# Generic inheritence
- From: Ido Samuelson
- Re: Feature request for C# Generic inheritence
- From: Ben Voigt [C++ MVP]
- Feature request for C# Generic inheritence
- Prev by Date: RE: System Directories
- Next by Date: Re: Interactive web map
- Previous by thread: Re: Feature request for C# Generic inheritence
- Next by thread: Re: Feature request for C# Generic inheritence
- Index(es):
Relevant Pages
|