Skip to content

Latest commit

 

History

History
68 lines (54 loc) · 1.79 KB

File metadata and controls

68 lines (54 loc) · 1.79 KB

How to use

Item of the list

Each item of the list is instance ToDoItem public class

Examples of using
var toDoItem = new ToDoItem(name:"Math homework",description: "Remember to finish math homework before the asignment ends");

var item2 = new ToDoItem
{
    Name="House work"
};
toDoItem.IsDone=true;
Console.WriteLine($"ToDo #{toDoItem.Id}, name:{toDoItem.Name}, description:{toDoItem.description}, is done:{toDoItem.IsDone}");

All double or more spaces/whitespaces would be removed from Name property of the ToDoItem class

"     aaaaa aaa    aaaaa a aaa aaa      " => "aaaaa aaa aaaaa a aaa aaa"

List overview

Code example

// Lets create some ToDoItem objects to insert them in list
var todos = new ToDoItem[] 
{
    new ToDoItem {"Item1"},
    new ToDoItem {"Item2"},
    new ToDoItem {"Item3"},
    new ToDoItem {"Item4"},
}

var list = new ToDoList(10); //Create empty list with capacity of 10, to save some memory
list.AddRange(todos); //Add elements with AddRange function
list.Add("Item5"); //Add item with passing name and description of the item
list[1].IsDone=true; //Activating some items
list[0].IsDone=true;
list[4].IsDone=true;

//Printing them to see
foreach(var item in list.Where(todo => todo.IsDone))
{
    Console.WriteLine($"ToDo #{todo.Id}, name:{todo.Name}, description:{todo.description}, is done:{todo.IsDone}");
}

//Or you can use built in function to get completed items
foreach(var item in list.GetCompletedItems())
{
    Console.WriteLine($"ToDo #{todo.Id}, name:{todo.Name}, description:{todo.description}, is done:{todo.IsDone}");
}

//Remove completed items
foreach(var item in list.Where(todo => todo.IsDone))
{
    list.Remove(item);
}

//Or again you can use built in function
list.RemoveCompletedItems();