I'm building a WCF. I have a class called Result
public class ReturnData
{
public string key { get; set; }
public string[] value { get; set; }
}
public class TagDetailData
{
public string key { get; set; }
public string description { get; set; }
}
public object Data { get; set; }
The response gives back property Data
and I would like to be able to convert a List<ReturnData>
or List<TagDetailData>
to Data
in the response.
Client is demanding that the result is all in Data
, and depending on their inputs I either process ReturnData
or TagDetailData
.
Can I convert a List into a object? Maybe I need another approach?
When I try
var newData = new List<TagDetailData>();
newData.Add(new TagDetailData
{
key = "Test",
description = "Tester"
});
this.Data = (List<TagDetailData>)newData;
The service simply fails to load response data and I don't get any Exceptions.