List allows you to store different types of data in a Node/List
type structure, example for List<string>:
("word") --> ("word") --> ("word") --> null
every List item contains the value and the 'address' to the next list item.
Add objects by using .Add() --> list.Add("word")
output:
("word") --> ("word") --> ("word") --> ("word") --> null
List<Action> functions = new List<Action>();
functions.Add(Move);
foreach (Action func in functions)
func();
List<string> listOfString = new List<string>();
listOfString.Add("georgel");
listOfString.Add("marcel");
for (int i = 0; i < listOfString.Count; i++)
{
Console.WriteLine("the strings are: " + listOfString[i]);
}
List<User> listOfUser = new List<User>()
{
new User() { Name = "john", Age = 22 },
new User() { Name = "john", Age = 44 },
};
for (int i = 0; i < listOfUser.Count; i++)
{
Console.WriteLine("the name is: " + listOfUser[i].Name + " and the age is: " + listOfUser[i].Age);
}
//USER CLASS
class User
{
public string Name { get; set; }
public int Age { get; set; }
}