From 83ab2ab491eb1843fccc818cc97d6609df4fc4fc Mon Sep 17 00:00:00 2001 From: Espen Luna Date: Tue, 13 Aug 2024 10:36:16 +0200 Subject: [PATCH] Finished task --- csharp-fundamentals-lists.Main/Core.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/csharp-fundamentals-lists.Main/Core.cs b/csharp-fundamentals-lists.Main/Core.cs index 185c6d3..db2d6b6 100644 --- a/csharp-fundamentals-lists.Main/Core.cs +++ b/csharp-fundamentals-lists.Main/Core.cs @@ -31,6 +31,8 @@ public List Question1() // TODO: 1. Find the add method and add two more flavours of ice cream: "Phish Food", "Peanut Butter Cup" //write code here + _iceCreams.Add("Phish Food"); + _iceCreams.Add("Peanut Butter cup"); return _iceCreams; } @@ -41,7 +43,7 @@ public int Question2() //TODO: find the lists method that returns the number of ice creams in the list and return this. // remove exception and write code here - throw new NotImplementedException(); + return _iceCreams.Count; } public List Question3() { @@ -49,7 +51,7 @@ public List Question3() // The code below concatenates this.MoreIceCream to the _iceCreams list into a new results list. //TODO: you can 'chain' methods on the _iceCream list, so add another Concat to include EvenMoreIceCream (this is defined below) to the result list . e.g. _iceCreams.Concat(this.MoreIceCream).Concat(other list to concat).ToList() - List results = _iceCreams.Concat(this.MoreIceCream).ToList(); + List results = _iceCreams.Concat(this.MoreIceCream).Concat(EvenMoreIceCream).ToList(); return results; @@ -65,7 +67,7 @@ public List Question4() // be sure to include the MoreIceCream and EvenMoreIceCream lists - List results = _iceCreams; + List results = _iceCreams.Concat(this.MoreIceCream).Distinct().ToList(); // remove exception and write code here return results; }