我的方法: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