Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- TasksList tl = new TasksList(new int[] { 1, 2, 3, 4, 5 });
- Console.WriteLine("The tasks list length " + tl.Tasks.Length);
- }
- }
- class Task
- {
- private readonly TasksList list;
- private readonly int id;
- public Task(TasksList list, int id)
- {
- this.list = list;
- this.id = id;
- }
- }
- class TasksList
- {
- private readonly Task[] tasks;
- public TasksList(int[] ids)
- {
- var mutableList = new List<Task>();
- foreach (int id in ids)
- {
- Task t = new Task(this, id);
- mutableList.Add(t);
- }
- this.tasks = mutableList.ToArray();
- }
- public Task[] Tasks { get { return tasks; } }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement