2016-02-01 92 views

回答

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"); 
相關問題