You need to add a user to the UserTracker instance.What should you do?

You are developing an application that includes a class named UserTracker. The application includes
the following code segment. (Line numbers are included for reference only.)

You need to add a user to the UserTracker instance.What should you do?

You are developing an application that includes a class named UserTracker. The application includes
the following code segment. (Line numbers are included for reference only.)

You need to add a user to the UserTracker instance.What should you do?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 2

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


Bob Viella

Bob Viella

if you step through the below code (I’m using linqpad) you’ll get the drift.

void Main()
{
Runner myRunner = new Runner();
myRunner.Add(“bob”);
myRunner.Add(“fred”);
}

// Define other methods and classes here
public delegate void AddUserCallback(int i);

public class UserTracker
{
public List users = new List();
public void AddUser(string name, AddUserCallback callback)
{
users.Add(new User(name));
callback(users.Count);
}
}

public class Runner
{
UserTracker tracker = new UserTracker();
public void Add(string name)
{
tracker.AddUser(name, delegate (int i)
{
Console.WriteLine(name + ” count ” + i);
});
}
}

public class User
{
public User(string name)
{this.name = name;}

string name { get; set; }
string address { get; set;}

}