vault backup: 2023-11-23 09:48:36
This commit is contained in:
parent
6d4ca16577
commit
2ee026bf6f
@ -1,3 +1,6 @@
|
|||||||
|
<center><img src="https://i.imgur.com/UWw1g20.png" /></center>
|
||||||
|
|
||||||
|
## System Collections
|
||||||
We have 3 collections namespace in C#
|
We have 3 collections namespace in C#
|
||||||
- System.Collections
|
- System.Collections
|
||||||
- Store items as Object
|
- Store items as Object
|
||||||
@ -13,4 +16,34 @@ We have 3 collections namespace in C#
|
|||||||
- Dictionary<TKey,TValue>
|
- Dictionary<TKey,TValue>
|
||||||
- System.Collections.Concurrent
|
- System.Collections.Concurrent
|
||||||
- As previous bu thread safe
|
- As previous bu thread safe
|
||||||
-
|
|
||||||
|
## Live coding
|
||||||
|
```csharp
|
||||||
|
namespace Lecture;
|
||||||
|
public static class Program {
|
||||||
|
public static void Main() {
|
||||||
|
var myList = new List<int>();
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user