I am trying to understand why I can't cast generic class to a class
of a base type. I have the following setup:
///////////////////////////////////////////////////////////////////
public class Personnel_List<T> :
ProjectCentral.GlobalObjects.PersistentObject_List<Person_Abs> where
T : Person_Abs, iPerson
{
}
public abstract class Person_Abs :
ProjectCentral.GlobalObjects.PersistentObject, Contacts.iPerson
{
}
public class Vendor_Person : Person
{
}
public class Contract_Person : Vendor_Person
{
////////////////////////////////////////////////
Ok so now I have a contract class that has a property Personnel_List
which is
/////////////////////////////////////////////////////////////
public class Contract :
ProjectCentral.GlobalObjects.PersistentObject, iContract
{
public
ProjectCentral.Contacts.Personnel_List<Contacts.Contract_Person>
Personnel_List
{
get
{ if (this._Personnel_List == null)
this._Personnel_List = new
Personnel_List<Contract_Person>();
return this._Personnel_List;
}
set
{
this.Personnel_List = value;
}
}
}
//////////////////////////////////////////////////////////////////
THen I have a usercontrol that I want to use everywhere to list
Personnel so I set up a property as follows:
//////////////////////////////////////////////////////////
public Personnel_List<Person> DataSource
{
get { return (Personnel_List<Person>)
grdPersonnel.DataSource; }
set {grdPersonnel.DataSource = value;}
}
////////////////////////////////////////////////////////////
So when I try to do this it bombs on me:
///////////////////////////////////////////////////////////////
UcPersonnelList1.DataSource = ((Contract)
this.ContractDetail1.DataSource).Personnel_List;
////////////////////////////////////////////////////////////
Even if I try this:
///////////////////////////////////////////////////////////////
UcPersonnelList1.DataSource = (Personnel_List<Person>)((Contract)
this.ContractDetail1.DataSource).Personnel_List;
////////////////////////////////////////////////////////////
ANy help would be greatly appreciated. My boss is starting to look
at me like I don't know what I'm doing.
SPONSORED LINKS
| Object oriented | Object oriented design | Object oriented language |
| Object oriented training | Object oriented methodology | Object oriented tutorial |
YAHOO! GROUPS LINKS
- Visit your group "StrongTypes" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
