Jon*_*Jon 2 c# arrays text-files
我想带一个包含很多行的文本文件并将其转换为数组.例如,如果文本文件是:
第1行
第2行
第3行
4号线
它会导致
string[] stringList = { "Line 1", "Line 2", "Line 3", "Line 4" };
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
我试过这个:
string line;
string[] accountList;
using (StreamReader file = new StreamReader(accountFileLocation.Text))
{
while (line = file.ReadLine() != null)
{
stringList += line;
}
}
Run Code Online (Sandbox Code Playgroud)
然而,错误:
无法将类型'bool'隐式转换为'string'
无法将'string'类型转换为'string []'
无法将类型'string'隐式转换为'string []'
| 归档时间: |
|
| 查看次数: |
235 次 |
| 最近记录: |