Serialization of a custom collection
- From: "TarTar" <spam.spam@xxxxxxxxxxx>
- Date: Thu, 29 Jan 2009 11:47:39 -0500
Hello,
I've created a custom collection:
[XmlRoot("Cars")]
public class CarCollection : List<Car>
{
private string errMsg;
[XmlElement("ErrorMessage")]
public string ErrorMessage { get { return errMsg; } set { errMsg =
value; } }
// some CarCollection-specific methods
// ...
}
[Serializable]
public struct Car
{
public string Model;
public string Make;
public Car(string model, string make)
{
this.Model = model;
this.Make = make;
}
}
.... and a Web Service method:
[WebMethod]
public CarCollection SearchCars()
{
CarCollection cars = GetCars();
cars.ErrorMessage = "Testing, testing...";
return cars;
}
When I call the web method it returns a collection of cars, but the
ErrorMessage element is missing.
How to properly enhance my custom collection? I'd like to serialize some
additional information such as ErrorMessage besides the collection itself.
I appreciate any help,
Leszek
.
- Follow-Ups:
- Re: Serialization of a custom collection
- From: Pavel Minaev
- Re: Serialization of a custom collection
- Prev by Date: Re: Is there a better way of doing it?
- Next by Date: Re: Integer conversion to Binary Coded Decimal
- Previous by thread: Is there a better way of doing it?
- Next by thread: Re: Serialization of a custom collection
- Index(es):
Relevant Pages
|