You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/solutions/data/lists.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,46 +46,46 @@ tags:
46
46
47
47
#. … a `IsEmpty` property that is `true` if the `CList` calling object is empty.
48
48
49
-
<details>
50
-
<summary>Solution</summary>
51
-
52
-
Note that the question asks for a *property*:
53
-
54
-
```
55
-
public bool IsEmpty{
56
-
get{ return first == null; }
57
-
}
58
-
```
59
-
</details>
49
+
<details>
50
+
<summary>Solution</summary>
51
+
52
+
Note that the question asks for a *property*:
53
+
54
+
```
55
+
public bool IsEmpty{
56
+
get{ return first == null; }
57
+
}
58
+
```
59
+
</details>
60
60
61
61
#. … the `AddF` method that add a cell at the beginning of the CList (to the left).
62
62
63
-
<details>
64
-
<summary>Solution</summary>
63
+
<details>
64
+
<summary>Solution</summary>
65
65
66
-
The key is to use the given `Cell` constructor to create the new element:
67
-
68
-
```
69
-
public void AddF(T dataP){
70
-
first = new Cell(dataP, first);
71
-
}
72
-
```
73
-
</details>
66
+
The key is to use the given `Cell` constructor to create the new element:
67
+
68
+
```
69
+
public void AddF(T dataP){
70
+
first = new Cell(dataP, first);
71
+
}
72
+
```
73
+
</details>
74
74
75
75
#. … a series of statements, to be inserted in a `Main` method, that a. create a `CList` object capable of containing `char`, b. insert the elements `'b'` and `'/'` in it, c. displays whether it is empty using `IsEmpty`.
76
76
77
-
<details>
78
-
<summary>Solution</summary>
79
-
80
-
Remembering that `IsEmpty` is a property, we obtain:
81
-
82
-
```
83
-
CList<char> myList1 = new CList<char>();
84
-
myList1.AddF('b');
85
-
myList1.AddF('/');
86
-
Console.WriteLine("myList1 is empty:" + myList1.IsEmpty);
87
-
```
88
-
</details>
77
+
<details>
78
+
<summary>Solution</summary>
79
+
80
+
Remembering that `IsEmpty` is a property, we obtain:
81
+
82
+
```
83
+
CList<char> myList1 = new CList<char>();
84
+
myList1.AddF('b');
85
+
myList1.AddF('/');
86
+
Console.WriteLine("myList1 is empty:" + myList1.IsEmpty);
87
+
```
88
+
</details>
89
89
90
90
#. Briefly explain the purpose of the `IsReadonly` property from the `ICollection<T>` interface, and list at least two methods in a List implementation realizing `ICollection<T>` that should use it.
0 commit comments