H
Helen
I have a person class with a name object. The name object has several
fields including one called "title". The two classes look something
like this:
public class name {
public string title {
// get set code here
}
}
public class person {
private gender;
private m_name;
public Name name {
get { return m_name; }
set { m_name = value; }
}
}
What I want to do is set the gender automatically when the title
property is set.
I know I could have a title property/setter method in Person that will
easily do this, but I'd prefer not to do this because it makes more
sense if title is a field of name (and then it'd be possible to
accidently set the title through name without it affecting the
gender).
I'm wondering if it's possible for person to override the title
property of name by declaring a property something like this:
public class person {
private gender;
private m_name;
public Name name {
get { return m_name; }
set { m_name = value; }
}
public string name.title {
set {
name.title = title;
// gender setting code here
}
}
}
Thanks
Helen
fields including one called "title". The two classes look something
like this:
public class name {
public string title {
// get set code here
}
}
public class person {
private gender;
private m_name;
public Name name {
get { return m_name; }
set { m_name = value; }
}
}
What I want to do is set the gender automatically when the title
property is set.
I know I could have a title property/setter method in Person that will
easily do this, but I'd prefer not to do this because it makes more
sense if title is a field of name (and then it'd be possible to
accidently set the title through name without it affecting the
gender).
I'm wondering if it's possible for person to override the title
property of name by declaring a property something like this:
public class person {
private gender;
private m_name;
public Name name {
get { return m_name; }
set { m_name = value; }
}
public string name.title {
set {
name.title = title;
// gender setting code here
}
}
}
Thanks

Helen