我有这段代码:
String[] lineElements;
. . .
try
{
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
lineElements = line.Split(',');
. . .
但后来我想也许应该使用列表。 但是这段代码:
List<String> listStrLineElements;
. . .
try
{
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
listStrLineElements = line.Split(',');
. . .
...给出了这个错误信息:"无法隐式将类型'string[]'转换为'System.Collections.Generic.List'"
sairfan
,将line
字符串按逗号分隔并转换为列表类型的操作。 - Vinigas