Casting a object to a base class , return the extented object??
Posted
by CrazyJoe
on Stack Overflow
See other posts from Stack Overflow
or by CrazyJoe
Published on 2010-04-13T19:12:26Z
Indexed on
2010/04/13
19:23 UTC
Read the original article
Hit count: 451
My Code:
public class Contact
{
public string id{ get; set; }
public string contact_type_id { get; set; }
public string value{ get; set; }
public string person_id { get; set; }
public Contact()
{
}
}
public class Contact:Base.Contact
{
public ContactType ContactType { get; set; }
public Person Person {get; set;}
public Contact()
{
ContactType = new ContactType();
Person = new Person();
}
}
And:
Contact c = new Contact();
Base.Contact cb = (Base.Contact)c;
The Problem:
The **cb** is set to **Contac** and not to **Base.Contact**.
Have any trick to do that????
© Stack Overflow or respective owner