views:

1340

answers:

3

my method:

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;
 }

The static method it calls

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;
 }

return class definition:

public class TableFilled<TKey,TRow> where TRow: STeraRow<TKey>
A: 

I believe the difference comes from not all items in the process having the where TRow : STeraRow<TKey> designation.

Mitchel Sellers
even the extension method has to have the same restriction?
Maslow
apparently not, it's compiling now that I fixed the type typo
Maslow
+2  A: 

So what is the difference between a TableFilled type and a TablesFilled type? Either you have a typo in your return type or you do not have an implicit conversion between the two types.

Randolpho
sorry they have the same signature, I edited it to have TableFilled showing
Maslow
But you can't convert from a TablesFilled to a TableFilled even if they've got the same definition - that's the problem. Do you *really* need to have two class names which only vary by a letter in the middle in the first place?
Jon Skeet
holy cow... yup that was the problem any suggestions for a better name for the filled pair of tables that is ready for comparing?
Maslow
A: 

Problem was the Func should have been returning a FilledTable instead of FilledTables

 abstract protected TableFilled<TKey, TRow> chGetTera();

 public TableFilled<TKey, TRow> getTera()
 {

  Func<TableFilled<TKey,TRow>> _getTera=new Func<TableFilled<TKey,TRow>>(
  ()=>{return  chGetTera();});

return _getTera.TimeAndReport("Finished Teradata",OutputIfListener);

 //return chGetTera();

 }
Maslow