Click here to Skip to main content
15,905,963 members
Home / Discussions / C#
   

C#

 
AnswerRe: Your favourite/best C# 2.0 Book? Pin
Andrei Ungureanu6-Sep-06 20:00
Andrei Ungureanu6-Sep-06 20:00 
QuestionHelp ThreadPools/Threads Pin
peterzorbas6-Sep-06 13:30
peterzorbas6-Sep-06 13:30 
QuestionCopy and Past shortcuts stop working when derived form shown non-modally. Pin
Vengeance6-Sep-06 12:50
Vengeance6-Sep-06 12:50 
Questiongeneric inherited class Pin
daveroberge6-Sep-06 9:33
daveroberge6-Sep-06 9:33 
AnswerRe: generic inherited class Pin
Nader Elshehabi6-Sep-06 10:17
Nader Elshehabi6-Sep-06 10:17 
GeneralRe: generic inherited class Pin
daveroberge6-Sep-06 10:46
daveroberge6-Sep-06 10:46 
QuestionRe: generic inherited class Pin
Nader Elshehabi6-Sep-06 11:30
Nader Elshehabi6-Sep-06 11:30 
AnswerRe: generic inherited class Pin
daveroberge6-Sep-06 14:04
daveroberge6-Sep-06 14:04 
Hope your night was good Big Grin | :-D
this is a better code :

interface I1<t> { void Add(t a); }

class c1{
public string sVal = "test";}

class c2 : c1{
public string sVal2 = "test2";}

class g1<t> : I1<t> where t : c1{
public virtual void Add(t a){a.sVal = "svalmodified";}}

class g2<t> : g1<c2> where t : c2 {
public override void Add(c2 a){
a.sVal2 = "testmodified2";
base.Add(a);}}

private I1<c1> GetG1(){
g1<c1> oG1 = new g1<c1>();
oG1.Add(new c1());
return oG1;}

private I1<c1> GetG2(){
g2<c2> oG2 = new g2<c2>();
oG2.Add(new c2());
return (I1<c1>)oG2;} ********* see below the error ********

private void TestMethod(){
I1<c1> oTest1 = GetG1();
I1<c1> oTest2 = GetG2();}

****** error ******
Unable to cast object of type 'WindowsApplication2.g2`1[WindowsApplication2.c2]' to type 'WindowsApplication2.I1`1[WindowsApplication2.c1]'

I hope it's less confusing... Wink | ;)
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 
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 

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.