我可以在我的列表后面附加HttpResponseMessage吗?例如:我有这个批准者列表,我需要将其附加到我的响应消息中。
List <string> Approvers = new List<string>();
foreach (ApproverEmployee item in SinglItem.ApproverList)
{
Approvers.Add(item.FullName + " , " + item.DesignationName);
}最后将列表与我的响应消息一起传递
return Request.CreateResponse(HttpStatusCode.Ok, "Request needs to be approved by following approvers: " + Approvers)但这并没有给我名单。我是否必须将列表转换为datatable,然后传递它?我不能直接获取列表吗?
发布于 2018-12-28 21:06:46
如果你不把你的列表连接成字符串,我想你会得到结果。
"string value" + lstHede 将调用lstHede的ToString方法。它将返回变量的类名。
public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, T value);您可以像这样编写代码:
var result = "Request needs to be approved by following approvers: ";
foreach (ApproverEmployee item in SinglItem.ApproverList) {
result += item.FullName + " , " + item.DesignationName;
}
return Request.CreateResponse(HttpStatusCode.Ok, result);https://stackoverflow.com/questions/53958261
复制相似问题