-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollectionsDemo.cs
52 lines (46 loc) · 1.09 KB
/
CollectionsDemo.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
namespace hello_world {
public class Arrays {
public Arrays() {
this.MakeArray();
}
public void MakeArray() {
int[] marks = new int[10];
for(int i=0; i<marks.Length; i++) {
marks[i] = i*i + i;
}
foreach(int mark in marks) {
Console.WriteLine($"Mark: {mark}");
}
}
}
public class Lists {
public Lists() {
this.MakeList();
}
public void MakeList() {
List<string> members = new List<string>();
members.Add("Adarsh");
members.Add("Arpit");
members.Add("Reshu");
foreach(string member in members) {
Console.WriteLine($"Name: {member}");
}
}
}
public class Dict {
public Dict() {
this.MakeDict();
}
public void MakeDict() {
Dictionary<string, int> grades = new Dictionary<string, int>();
grades.Add("Adarsh", 92);
grades.Add("Arpit", 98);
grades.Add("Ankur", 75);
foreach(KeyValuePair<string,int> person in grades) {
Console.WriteLine(person);
}
}
}
}