PrepAway - Latest Free Exam Questions & Answers

You need to add a user to the UserTracker instance

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?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

One Comment on “You need to add a user to the UserTracker instance

  1. Swapnil says:

    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




    5



    0

Leave a Reply