我想作为字符串返回 [英] i want to return as string
本文介绍了我想作为字符串返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我无法在课堂上从列表转换为字符串.
即我在webservice中有一个返回列表的类.
现在我想转换为字符串.
我该怎么办.
请给我建议,
在此先感谢.
这是我的代码:
Hi all,
i didn''t able to convert from list to string in my class.
i.e i have a class in webservice which returns list .
now i want to convert into string.
how can i will do.
pls advice to me,
Thanks in Advance.
here my code:
[WebMethod]
public List<employeeinformation> GetAllInfor()
{
DataClasses1DataContext dbcontext = new DataClasses1DataContext();
var EMPLOYEEEntity = (from p in dbcontext.EMPLOYEEInformations select p);
return EMPLOYEEEntity.ToList();
}
现在我想返回字符串..
now i want to return string ..
推荐答案
如何处理:
http://www.dotnetperls.com/convert-list-string [
How about this:
http://www.dotnetperls.com/convert-list-string[^]
Code:
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> dogs = new List<string>(); // Create new list of strings
dogs.Add("Aigi"); // Add string 1
dogs.Add("Spitz"); // 2
dogs.Add("Mastiff"); // 3
dogs.Add("Finnish Spitz"); // 4
dogs.Add("Briard"); // 5
string dogCsv = string.Join(",", dogs.ToArray());
Console.WriteLine(dogCsv);
}
}
List<string> names = new List<string>() { "John", "Anna", "Monica" };
var result = String.Join(", ", names.ToArray());
或
or
var names = new List<string>() { "John", "Anna", "Monica" };
var joinedNames = names.Aggregate((a, b) => a + ", " + b);
http://stackoverflow.com/questions/3575029/c-sharp-liststring- to-string-with-delimiter [ ^ ]
http://stackoverflow.com/questions/3575029/c-sharp-liststring-to-string-with-delimiter[^]
这篇关于我想作为字符串返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文