c# - Delegate Action Lambda with class Person -


i have following problem: want make lambda, should print result of class person. print should this: resetname, after (name ==null) = true error on p. , printed out is: naam persoon voor = alfrednaam persoon na =

        person per = new person();         per.name = "alfred";         output.appendformat("naam persoon voor = " + per.name);          action<person> resetname = (person p) => { p.name = null; };         resetname(per);         output.appendformat("naam persoon na = " + per.name);          person p1 = new person();         person p2 = new person();          p1.name = "karel";         p2.name = "freek";          methods.resetname(p1);         resetname(p2);          if (p1.name != p2.name) { passed = false; console.writeline("error in resetperson"); }          return output.tostring(); 

it if provide a good, minimal, complete code example, , more clear problem statement. in particular:

  • show implementation of methods.resetname(), since resetname delegate apparently supposed have same effect method.
  • explain in precise terms both actual effect of code should and actual output want (the text provided sample output — resetname, after (name ==null) = true — not real output me, instead looks more description of code's effect)

that said, seems possible m want this:

action<person> resetname = (person p) => {     p.name = null;     output.appendformat("naam persoon na = " + p.name); }; resetname(per); 

if not address question, please edit question clear , answerable. see https://stackoverflow.com/help/how-to-ask advice on other ways improve question.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -