-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicCsharp_List.cs
More file actions
47 lines (40 loc) · 1.15 KB
/
BasicCsharp_List.cs
File metadata and controls
47 lines (40 loc) · 1.15 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 1. Init different data structures
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
// 1.1 Init List with input content
List<string> list1 = new List<string>()
{
"carrot",
"fox",
"exploer"
};
var list2 = new List<string>()
{
"carrot",
"fox",
"exploer"
};
// 1.2 Init List with array as input
string[] array = {"carrot", "fox", "exploer"};
List<string> list3 = new List<string>(array);
// 1.3 Init List with capacity
List<string> list4 = new List<string>(3);
list4.Add(null);
list4.Add(null);
list4.Add(null);
list4[0] = "carrot";
list4[1] = "fox";
list4[2] = "exploer";
// 1.4 use Add method with unspecified pre condi
List<string> list5 = new List<string>();
list5.Add("carrot");
list5.Add("fox");
list5.Add("exploer");
// 2. Dictionary with Tuple
public Dictionary<Tuple<string, int>, int> store = new Dictionary<Tuple<string, int>, int>();
}
}