C#C
C#3y ago
75 replies
r2d25551

❔ Class with Func<> and class initializers

If I define a class with members to be passed to known create type functions how do I set the Func<> member to the known function?

For example,
public class Known
{
     public string param1;
     public string param2;
     public IRet myObj;
     public Func<string, string, IRet> Create;
}

Dictionay<string, Known> myData = new Dictionary<string, Known>()
{
     {
          "one",                                       // dictionary key
          {
               "abc",                                  // func parameters
               "xyz",
               null,                                   // func returrn value

               CreateFunc,                             // PROBLEM HERE?
          }
     }
};


public static IRet CreateFunc(string param1, string param2)
{
     IRet iret = new IRet(param1, param2);
     return iret;
}


Thank you in advance.
Was this page helpful?