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.)

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.)

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!)



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Guilherme Morais

Guilherme Morais

Hi!
The options to select are not for the method GetResponse, would be a switch not a delegate right!?

Marianne

Marianne

No, this one doesn’t seem to make much sense to me either…

Zain

Zain

correct answer :

user.Renamed += (sender , e) =>
user.Add(user);

devprof

devprof

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

visit the up coming internet page

visit the up coming internet page

hi!,I love your writing so much! percentage we be in contact more about your article on AOL? I need an expert on this area to resolve my problem. May be that is you! Having a look ahead to look you. |