パラメータとジェネリック型をとるメソッドreadExcelFile()を持っています。ジェネリック型はクラスなので、このメソッドにはこのメソッドを渡す必要があります。 。インターフェイスでIList を定義するにはどうすればいいですか
すべて正常に動作している状態以上が、私はまた、インターフェースに
public interface IProcessExcel
{
IList<T> ReadExcelFile(string filePath, int readExcelRowFrom, int headerRow);
}
を定義する必要があり、上記のコードでは、私はエラー
The Type or namespace T could not be found(missing directive or assembly)
実装コード
public class ProcessExcel<T>: IProcessExcel where T: class
{
private static Excel.Application xlApp;
private static Excel.Workbook xlWorkbook;
private static Excel.Worksheet xlWorkSheet;
private static Excel.Range xlRange;
private string GivenFilePath = string.Empty;
private IList<string> ExcelFileExtensionList = new string[] { ".xls", ".xlsx", ".xlsm", ".xltx", ".xltm" };
private T newObject;
List<T> ExcelRecordList = new List<T>();
public ProcessExcel()
{
}
public IList<T> ReadExcelFile(string filePath, int readExcelRowFrom, int headerRow)
{
this.FilePath = filePath;
this.ReadExcelRowFrom = readExcelRowFrom;
this.HeaderRow = headerRow;
this.ReferenceClass = typeof(T);
this.ValidateExcelFile();
this.ProcessReadExcelFile();
return ReadExcelFile;
}
これは実装クラスの実装が変更されたことを意味します。 – toxic
いいえ、そうではありません。それはインスタンス化の際に 'T'を定義させます。 –