我正在尝试使用所示的类创建一个类库。但我遇到了错误。 我以为在创建对象时会调用构造函数,为什么它已经需要参数了?
我正在使用Visual Studio 2019和.NET Framework 4.8
如果我在15行添加评论,则前两个错误会消失
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSVDataViewer
{
class CSV
{
public List<string> FirstColumn { get; set; }
public List<string> SecondColumn { get; set; }
// Line 15
public CSV(string path, char separator)
{
using (var reader = new StreamReader(path))
{
List<string> listA = new List<string>();
List<string> listB = new List<string>();
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(separator);
listA.Add(values[0]);
listB.Add(values[1]);
}
}
}
}
}
CS1056 Unexpected character ''
在第15行CS1519 Invalid token '' in class, struct or interface member declaration
在第15行CS1056 Unexpected character ''
在第26行