我希望在我的规范列表中连接字符串,但它们互相替换而不是连接。这是代码。我使用了string.join,string.concat和聚合方法,但没有一个能够完成它们的工作。
List<string> norm = new List<string>();
Application application = new Application();
Document doc = application.Documents.Open(@"E:\abdullah\import.docx",false,true);
foreach (Paragraph paragraph in doc.Paragraphs)
{
Style style = paragraph.get_Style() as Style;
string styleName = style.NameLocal;
int count = 0;
if (styleName == "Heading 1")
{
count++;
}
else
{
string text = paragraph.Range.Text;
norm.Add(text);
}
}
for (int i = 0; i < norm.Count;i++)
{
Console.WriteLine(norm[i]);
}
string a=string.Join(string.Empty, norm);
Console.WriteLine(a);
doc.Close();
application.Quit();
Console.ReadKey();
答案 0 :(得分:0)
您是否尝试过使用StringBuilder?
var sb = new StringBuilder();
foreach (var nor in norm)
{
sb.Append(nor);
}
Console.WriteLine(sb.ToString());