我的方法:C#不能隱式轉換類型T爲T類型
public TableFilled<TKey, TRow> getTera()
{
Func<TablesFilled<TKey,TRow>> _getTera=new Func<TablesFilled<TKey,TRow>>(
()=>{return (TablesFilled<TKey,TRow>) chGetTera();});
//Above does not compile says: Cannot convert type
//'AcapsVerify.FunctionalTables.TableFilled<TKey,TRow>' to
//'AcapsVerify.FunctionalTables.TablesFilled<TKey,TRow>'
// the line below has the same blue underline error.
return _getTera.TimeAndReport("Finished Teradata",OutputIfListener);
// this works fine
return chGetTera;
}
靜態方法調用
public static T TimeAndReport<T>(this Func<T> timedFunc, String reportLead, Action<String> reporterAction)
{
T result;
var s = new System.Diagnostics.Stopwatch();
s.Start();
result = timedFunc();
s.Stop();
reporterAction(reportLead + " in " + s.WholePartOnly());
return result;
}
回報類的定義:
public class TableFilled<TKey,TRow> where TRow: STeraRow<TKey>
要把它放到更多的情況下,我正在做一個功能表比較程序,其中一個是主表,一個是複製。在功能上,填充表與構建它的類不同。我想讓所有的餐桌工廠報告,如果有人在傾聽,他們會花多長時間。 – Maslow 2009-07-17 19:52:36