-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCollections.cs
31 lines (28 loc) · 922 Bytes
/
Collections.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Collections in C# are used to store a collection of objects or data.
* It is a more flexible way to store data than arrays.
* Unlike arrays, collections can grow and shrink dynamically as the needs of the application change.
* For some collections, we can assign a key to any object that we put into the collection, so that we can retrieve the object by using the key.
*
* A collection is a class, so we need to create an object of the collection class to use it.
*/
using System;
using System.Collections;
namespace Basics
{
class Collections
{
public void List()
{
ArrayList list = new ArrayList();
list.Add(1);
list.Add("Person");
list.Add(10.5);
foreach (var item in list)
{
Console.WriteLine(item);
}
Console.WriteLine($"Count: {list.Count}");
}
}
}