From aa62466639142f10957828556a0ee47b58325e03 Mon Sep 17 00:00:00 2001 From: Patrick Schuur Date: Tue, 19 Aug 2025 13:57:08 +0200 Subject: [PATCH] Finished --- .gitignore | 3 +++ csharp-fundamentals-lists.Main/Core.cs | 18 +++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 9491a2f..99766dc 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Jetbrains Project Files +.idea/ + # Mono auto generated files mono_crash.* diff --git a/csharp-fundamentals-lists.Main/Core.cs b/csharp-fundamentals-lists.Main/Core.cs index 185c6d3..1d6cc03 100644 --- a/csharp-fundamentals-lists.Main/Core.cs +++ b/csharp-fundamentals-lists.Main/Core.cs @@ -31,17 +31,16 @@ 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; } 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,12 +48,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(); - - return results; - - // remove exception and write code here - + return _iceCreams.Concat(MoreIceCream).Concat(EvenMoreIceCream).ToList(); } public List Question4() { @@ -65,9 +59,7 @@ public List Question4() // be sure to include the MoreIceCream and EvenMoreIceCream lists - List results = _iceCreams; - // remove exception and write code here - return results; + return _iceCreams.Concat(MoreIceCream).Concat(EvenMoreIceCream).Distinct().ToList(); } public List MoreIceCream = new List()