Click here to Skip to main content
15,902,636 members
Home / Discussions / C#
   

C#

 
AnswerRe: generic inherited class Pin
daveroberge6-Sep-06 14:04
daveroberge6-Sep-06 14:04 
AnswerRe: generic inherited class Pin
Nader Elshehabi7-Sep-06 1:59
Nader Elshehabi7-Sep-06 1:59 
GeneralRe: generic inherited class Pin
daveroberge7-Sep-06 3:07
daveroberge7-Sep-06 3:07 
GeneralRe: generic inherited class Pin
Nader Elshehabi7-Sep-06 9:04
Nader Elshehabi7-Sep-06 9:04 
GeneralRe: generic inherited class Pin
daveroberge7-Sep-06 10:53
daveroberge7-Sep-06 10:53 
GeneralRe: generic inherited class Pin
Nader Elshehabi7-Sep-06 11:26
Nader Elshehabi7-Sep-06 11:26 
GeneralRe: generic inherited class Pin
daveroberge7-Sep-06 14:31
daveroberge7-Sep-06 14:31 
AnswerRe: generic inherited class Pin
Ed.Poore6-Sep-06 12:01
Ed.Poore6-Sep-06 12:01 
First of all (I don't know if this is because you stipped out the <> tags), your interface I1 does not expose a generic type, it should be declared as
interface I1<T>
{
	void meth(T t);
}
Unless of course I1 is declared inside another generic class which exposes the generic type T, but from your code this is not the case.

The same applies for the declarations of g1 and g2, you need to include the <T> after the name (unless it's part of a parent class).  Then everything should work.  Although in your lines of code which create the generics you will need to specify which type to implement: e.g.
I1 ol1 = null;
g2 = og2 = new g2<int>();
ol1 = (I1) og2;
So in summary your code should probably look along the lines of
class c1
{
}
class c2 : c1
{
}

interface I1<T>
{
    void meth(T t);
    {
    }
}

class g1<T> : I1 where T : c1
{
}
class g2<T> : g1 where T : c2
{
}

static void Main(...)
{
    I1<object> oI1 = null;
    g2 og2 = new g2<object>();
    oI1 = (I1)og2;
}
Of couse this would be much nicer if the variables and types were named more appropriately.



As of how to accomplish this I have no idea, have you tried Google?
Faiing that try Badger | [badger,badger,badger,badger...] Badger | [badger,badger,badger,badger...] Badger | [badger,badger,badger,badger...]

GeneralRe: generic inherited class Pin
daveroberge6-Sep-06 14:09
daveroberge6-Sep-06 14:09 
GeneralRe: generic inherited class Pin
Ed.Poore6-Sep-06 18:38
Ed.Poore6-Sep-06 18:38 
GeneralRe: generic inherited class Pin
daveroberge7-Sep-06 2:54
daveroberge7-Sep-06 2:54 
QuestionPlacing description into a class/method??? Pin
Goalie356-Sep-06 8:55
Goalie356-Sep-06 8:55 
AnswerRe: Placing description into a class/method??? Pin
Nader Elshehabi6-Sep-06 9:13
Nader Elshehabi6-Sep-06 9:13 
GeneralRe: Placing description into a class/method??? Pin
Goalie356-Sep-06 9:31
Goalie356-Sep-06 9:31 
GeneralRe: Placing description into a class/method??? Pin
Nader Elshehabi6-Sep-06 9:46
Nader Elshehabi6-Sep-06 9:46 
JokeRe: Placing description into a class/method??? Pin
Not Active6-Sep-06 9:56
mentorNot Active6-Sep-06 9:56 
JokeRe: Placing description into a class/method??? Pin
Nader Elshehabi6-Sep-06 10:36
Nader Elshehabi6-Sep-06 10:36 
QuestionHTML to MS Word or RTF Pin
Nadia Monalisa6-Sep-06 8:27
Nadia Monalisa6-Sep-06 8:27 
AnswerRe: HTML to MS Word or RTF Pin
led mike6-Sep-06 10:18
led mike6-Sep-06 10:18 
GeneralRe: HTML to MS Word or RTF Pin
Nadia Monalisa6-Sep-06 10:23
Nadia Monalisa6-Sep-06 10:23 
GeneralRe: HTML to MS Word or RTF Pin
led mike6-Sep-06 10:37
led mike6-Sep-06 10:37 
GeneralRe: HTML to MS Word or RTF Pin
Ed.Poore6-Sep-06 10:38
Ed.Poore6-Sep-06 10:38 
GeneralRe: HTML to MS Word or RTF Pin
Nadia Monalisa7-Sep-06 9:47
Nadia Monalisa7-Sep-06 9:47 
GeneralRe: HTML to MS Word or RTF Pin
Ed.Poore7-Sep-06 11:00
Ed.Poore7-Sep-06 11:00 
QuestionGloooooooble Variables Pin
Syed Shahid Hussain6-Sep-06 8:23
Syed Shahid Hussain6-Sep-06 8:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.