public class SampleFile<Toriginal>
{
public SampleFile(File filename,string sname)
{
}
}
How to pass a values to Samplefile
constructor?
File
is a static class, you can't pass it as a parameter.
Change it to a 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);
}
}
Then just call it normally:
var sample = new SampleFile<Type>(@"c:\hi.txt", "bye.txt");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.