jeudi 3 décembre 2015

anonymous method in example on MSDN what is the class made of?

In my search to understand Lambdas to use in a Moq unitTest , I have came across this document on MSDN and Now I am entirely confused on how I would build the Printer Class , what variables would be an instance ?

    private static void example04_anonymousMethods()
    {
        Printer p = delegate (string j)
        {
            Console.WriteLine(j);
        };

        p(" anonymous called");

        p = new Printer(DoWork);

        p("named called");

    }

    internal class Printer
    {
          // ?
    }

    static void DoWork(string k) { Console.WriteLine(k); }

Bonus digital smiles for any suggestions on a moq tutorial for people that have never used lambda's before ( IE Java developers that used pre-java7, and does most code in javaScript so unitTesting is like ehh)

Aucun commentaire:

Enregistrer un commentaire