本文介绍了如何将string []格式转换为字符串格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在服务器路径data.txt上有一个文件。它包含一个json字符串。如何将该数据提取为可用字符串。如何将string []格式转换为字符串格式?
I have a file on the server path "data.txt". It contains a json string. How do I extract that data to a usable string. How do you convert string[] format to string format?
string[] lines = File.ReadAllLines(Server.MapPath("~/data.txt"));
推荐答案
// Use string Join to concatenate the string elements.
string result = string.Join("\n", lines);
示例2
Example No 2
// Concatenate all the elements into a StringBuilder.
StringBuilder builder = new StringBuilder();
foreach (string value in lines)
{
builder.Append(value);
builder.Append('.');
}
string result = builder.ToString();
请查看以下链接
[]
这篇关于如何将string []格式转换为字符串格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!