T
TarTar
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
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