I have to parent class such as:
public class Title
{
public List<Detail> details {get; set;}
}
public class Detail
{
// some properties
}
public class TitleChild : Title
{
public new List<DetailChild> details {get; set;} // hiding
}
public class DetailChild : Detail
{
// some properties
}
I need to serialize a list of Title List<Title>
and list of TitleChild List<TitleChild>
Everythings is ok in List<Title>
but in List<TitleClild>
some things are wrong. After deserializing it in javascript I notice that the details properties steel is the hidden property in the superclass.
What should I do ?
And also I can't ignore serializing on hidden property is superclass because I need it in serializing time on the superclass.
Serialization most likely just traverses public properties. You have hidden your details on purpose with the new
keyword. You can try changing the structure so that you do not use new
. It seems rather weird in here really and you'd better avoid it in any case.
Eg if you want both properties back, you can change the name of details
to childrenDetails
and remove new
.
PS Since your DetailChild
inherits from Detail
, you can really just use the original details
list and populate it with DetailChild
objects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.