From 0927e3b2875e44e8fba620f27a432f9f1f606f63 Mon Sep 17 00:00:00 2001 From: Kristian Sylte Date: Wed, 8 Jan 2025 11:17:24 +0100 Subject: [PATCH] done --- csharp-fundamentals-lists.Main/Core.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/csharp-fundamentals-lists.Main/Core.cs b/csharp-fundamentals-lists.Main/Core.cs index 185c6d3..7662f2b 100644 --- a/csharp-fundamentals-lists.Main/Core.cs +++ b/csharp-fundamentals-lists.Main/Core.cs @@ -29,7 +29,7 @@ public List Question1() // declares a List which is a collection of strings. // by typing _iceCreams. intellisense shows all of the methods associated with the _inceCreams list. // TODO: 1. Find the add method and add two more flavours of ice cream: "Phish Food", "Peanut Butter Cup" - + _iceCreams.AddRange(["Phish Food", "Peanut Butter Cup"]); //write code here return _iceCreams; @@ -37,11 +37,11 @@ public List Question1() 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 +49,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(this.EvenMoreIceCream).ToList(); return results; @@ -64,6 +64,7 @@ public List Question4() // copy the List declaration line from Question3 and add the .Distinct() into the chain. e.g. _iceCreams.Concat(this.MoreIceCream).Concat(other list to concat).Distinct().ToList() // be sure to include the MoreIceCream and EvenMoreIceCream lists + return _iceCreams.Concat(this.MoreIceCream).Concat(this.EvenMoreIceCream).Distinct().ToList(); List results = _iceCreams; // remove exception and write code here