From a2e7db675ef4736a560ef1347e0e8ad45dceea25 Mon Sep 17 00:00:00 2001 From: Sini Suihkonen Date: Wed, 10 Jan 2024 15:50:50 +0200 Subject: [PATCH] List exercises done --- csharp-fundamentals-lists.Main/Core.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/csharp-fundamentals-lists.Main/Core.cs b/csharp-fundamentals-lists.Main/Core.cs index 185c6d3..103fd84 100644 --- a/csharp-fundamentals-lists.Main/Core.cs +++ b/csharp-fundamentals-lists.Main/Core.cs @@ -32,6 +32,9 @@ public List Question1() //write code here + _iceCreams.Add("Phish Food"); + _iceCreams.Add("Peanut Butter Cup"); + return _iceCreams; } @@ -41,7 +44,8 @@ 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(); + //throw new NotImplementedException(); + return _iceCreams.Count; } public List Question3() { @@ -49,7 +53,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; @@ -65,7 +69,7 @@ public List Question4() // be sure to include the MoreIceCream and EvenMoreIceCream lists - List results = _iceCreams; + List results = _iceCreams.Concat(this.MoreIceCream).Concat(this.EvenMoreIceCream).Distinct().ToList(); // remove exception and write code here return results; }