PrepAway - Latest Free Exam Questions & Answers

How should you complete the relevant code?

You are implementing a method that creates an instance of a class named User. The User class contains a
public event named Renamed. The following code segment defines the Renamed event: Public event
EventHandler<RenameEventArgs> Renamed;
You need to create an event handler for the Renamedevent by using a lambda expression.
How should you complete the relevant code? (To answer, drag the appropriate code segments to the
correct locations in the answer area. Each code segment may be used once, more than once, or not at all.
You may need to drag the split bar between panes orscroll to view content.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
This is only the answer slide. It should be
1. Users[0]=user;
2. User.Renamed += (sender,e)=>,
3. User.Renamed += (sender,e)=>,
4. User.Renamed += delegate(object sender, RenamedEventArgs e)
(please note that the yellow areas are where these should be dragged, but they got cut off!)

6 Comments on “How should you complete the relevant code?

  1. devprof says:

    the second part of question is not correct. It’s like that:
    List users = new List();
    public void AddUser(string name)
    {
    User user = new User(name);
    user.Renamed += (sender,e)=>
    {
    Log(“User {0} was renamed to {1}”, e.OldName, e.Name);
    };
    user.Add(user);
    }




    2



    0

Leave a Reply