Funny thing is that I did exactly what you're talking about.
interface ILetter
{
}
class A : ILetter
{
private string _ID;
public string ID
{
get { return this._ID; }
set { this._ID = value; }
}
}
class B : A, ILetter
{
}
THen I have a button do the following:
private void button1_Click(object sender, EventArgs e)
{
Letters<B> L = new Letters<B>();
B oB = new B();
oB.ID = "1";
L.Add(oB.ID, oB);
Letters<ILetter> L2 = L;
}
I get : Error 1 Cannot implicitly convert type
'ProjectCentral_TESTAPP.Letters<ProjectCentral_TESTAPP.B>' to
'ProjectCentral_TESTAPP.Letters<ProjectCentral_TESTAPP.ILetter>'
C:\Projects\Vs2005\ProjectCentral\Libraries\ProjectCentral_TESTAPP\ProjectCentra\
l_TESTAPP\Form1.cs
40 35 ProjectCentral_TESTAPP
If try this I get the same thing:
Letters<A> L2 = L;
or
Letters<A> L2 = (Letters<A>)L;
I thought with Inheritance I could always cast a sublass to it's base.
What the heck???
FUnny thing is I can do this: A oA = oB;
but I can't do it with the generics
Santiago Perez
Florida's Turnpike Enterprise
Programmer Analyst
Pompano Operations
Ph 954-975-4855 ex 1127
Cell 954-444-9429