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
public delegate void AddUserCallback(int i);
public class User
{
public User(string name)
{
Name = name;
}
public string Name { get; set; }
}
public class UserTracker
{
List user = new List();
public void AddUser(string name,AddUserCallback callback)
{
user.Add(new User(name));
callback(user.Count);
}
}
class Program
{
static void Main(string[] args)
{
UserTracker tracker = new UserTracker();
tracker.AddUser(“Sachin”, delegate (int i)
{
Console.WriteLine(“Count :” + i);
});
tracker.AddUser(“SAurav”, delegate (int i)
{
Console.WriteLine(“Count :” + i);
});
Console.ReadLine();
}
}
D is Right