我有一个名为message的MailMessage对象。
我正在尝试创建message.Body,但我只有一个IList可以填充它。
在正文中,我需要以下内容:
"The following files could not be converted-" + IList<string> testlist?
发布于 2010-11-24 05:51:07
StringBuilder builder = new StringBuilder("The following files could not be converted-\n");
foreach(string s in testlist)
builder.AppendFormat("{0}\n", s);
string body = builder.ToString();发布于 2010-11-24 05:53:47
var body = string.Format("The following files could not be converted-{0}.", string.Join(", ", testlist.ToArray()));例如,您可以使用"\n“而不是",”来调整布局。
发布于 2010-11-24 05:54:02
我会把你的IList转换成CSV字符串值。string.Join()函数应该对此有所帮助。
下面是我想不到的代码,所以它可能不能工作,但希望它能给你一些启发。
IList<string> x = new List<string>();
x.Add("file1");
x.Add("file2");
string message = "The following files could not be converted: " + string.Join(", ", x.ToArray());https://stackoverflow.com/questions/4261303
复制相似问题