Skip to content

Hans Jakob Håland #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions csharp-fundamentals-lists.Main/Core.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;

Expand Down Expand Up @@ -31,17 +32,17 @@ public List<string> 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();
//TODO: find the lists method that returns the number of ice creams in the list and return this.
return _iceCreams.Count;
}
public List<string> Question3()
{
Expand All @@ -50,7 +51,9 @@ public List<string> Question3()
//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<string> results = _iceCreams.Concat(this.MoreIceCream).ToList();


results = _iceCreams.Concat(this.EvenMoreIceCream).ToList();

return results;

// remove exception and write code here
Expand All @@ -63,9 +66,10 @@ public List<string> Question4()
//TODO: Remove the duplicates using the .Distinct() placing just before the .ToList()
// 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
List<string> results = _iceCreams.Concat(this.MoreIceCream).ToList();

results = _iceCreams.Concat(this.EvenMoreIceCream).Distinct().ToList();

List<string> results = _iceCreams;
// remove exception and write code here
return results;
}
Expand Down
Loading