public class SampleFile<Toriginal>
{
public SampleFile(File filename,string sname)
{
}
}
如何将值传递给Samplefile
构造函数?
答案 0 :(得分:2)
File
是一个静态类,您无法将其作为参数传递。
将其更改为string
:
public class SampleFile<Toriginal>
{
public SampleFile(string filename,string sname)
{
//Here you can use File as it is static
var lines = File.ReadAllLines(filename);
}
}
然后只需正常调用它:
var sample = new SampleFile<Type>(@"c:\hi.txt", "bye.txt");