-2
我需要一个DTO对象类转换是这样的:转换复杂对象字典<字符串,字符串>
public class ComplexDto
{
public ComplexDto()
{
ListIds = new List<ListIdsDto>();
}
public string Propertie1 { get; set; }
public string Propertie2 { get; set; }
public IList<int> ListIds { get; set; }
}
到dictionary<string,string>
。
这仅仅是一些类的例子,这个类将被用作JSON对象是这样的:
{"Propertie1":"ss","Propertie2":"","ListIds":[1,2,3]}
我需要此对象传递给一个FormUrlEncodedContent(字典)作为字符串的词典。
我有这样的:
var data = new Dictionary<string, string>();
data[string.Empty] = ComplexDto.ToJson();
而且我想到ComplexDto.ToJson()或ComplexDto对象变换为词典字符串,字符串。
任何想法?
什么是ListIdsDto?也只有一个类,你想用于字典的集合在哪里? – 2014-10-29 10:24:16
什么是应该转换为什么? – 2014-10-29 10:24:20
你究竟希望'ComplexDto'看起来像一个字符串? – 2014-10-29 10:25:16