You should add the a PhoneInfo object to the ContactInfo class and make a
property for it that can be called by other objects. You should also make a
property in the PhoneInfo class that returns the mobile phone number.
Similary you can addd more properties as you see fit, but the code below
allows you to get the mobile phone number of a contact like this:
ContactInfo myContactInfo = new ContactInfo(...); //depending on how you set
up your constructor
string mobileNum = myContactInfo.PhoneData.Mobile;
-------------------------------------------------------------------------
class ContactInfo
{
string m_name;
string m_department;
PhoneInfo m_phoneData;
public PhoneInfo PhoneData
{
get { return m_phoneData; }
}
....
}
class PhoneInfo
{
string m_officeNum;
string m_mobileNum;
public string Mobile
{
get { return m_mobileNum; }
}
....
}
Adrian.
--
[Please mark my answer if it was helpful to you]
"jack" wrote:
Hi,
I am creating an address book example. For the purpose i have created
2 classes
one is
ContactInfo
name
department
PhoneInfo
OfficePhone
Mobile
Now I want to design the class in such a way that when I type
ContactInfo.PhoneInfo.mobile
it should take the list of mobile numbers
im using dotnet 2.0 and know little about generics.
can we implement generics for the same.