diff --git a/Prog/Collections.md b/Prog/Collections.md index 34b2cd5..0878487 100644 --- a/Prog/Collections.md +++ b/Prog/Collections.md @@ -1,3 +1,6 @@ +
+ +## System Collections We have 3 collections namespace in C# - System.Collections - Store items as Object @@ -13,4 +16,34 @@ We have 3 collections namespace in C# - Dictionary - System.Collections.Concurrent - As previous bu thread safe -- \ No newline at end of file + +## Live coding +```csharp +namespace Lecture; +public static class Program { + public static void Main() { + var myList = new List(); + myList.Add(12); + myList.Add(23); + myList.Add(122); + myList.Add(312); + myList.Add(142); + + myList[4] = 1; + + int a = myList[5]; + + Console.WriteLine($"{myList}"); // Will return the type of the list and the value + Console.WriteLine(a); // Will return the value a (myList[5]) + foreach (var element in myList) { + Console.WriteLine($"{element}"); + } // Will display each element of the list + myList.ForEach(x => Console.WriteLine($"{x}")); // Same thing that foreach bellow + + var t = myList.GetRange(3, 2); + t.ForEach(x => Console.WriteLine($"{x}")); + myList.sort(); + myList. + } + +} \ No newline at end of file