Closed aksnell closed 4 years ago
This
return data.Select((str, index) => str + $" is at index {index}");
can be
return data.Select((str, index) => $"{str} is at index {index}");
If you are already using string interpolation, use it for both variables.
Also, no str variable names please.
return data.Select((str, index) => new { str = str, index = index}).First(selected => selected.str.Contains("needle")).index;
Nicely done. (also no str
variables pleas) - However, this would be easier using FindIndex
-- we did not cover it in class or the reading, but it is a method on List
that uses an expression and returns the index of the found match. https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.findindex?view=netcore-3.1
Your homework 02 - 02 C# Iteration - Working with LINQ was marked: Meets Expectations
“Well done!” — via Gavin Stark
Learning programming takes practice and the best practice is repetition. This exercise will allow you time to work on the basics of .NET and how to apply that logic to solving problems.
Objectives
After completing this assignment, you should be able to:
Instructions
git clone https://github.com/YOUR_NAME_HERE/net-iteration
cd net-iteration
dotnet restore
code .
dotnet watch test
Iterations.cs
and work on functions until the test passes. Once you are done with a test you can move to the next one by removing the(Skip = "Remove to run test")
from theFact
attribute. There are a total of 10 questions.Explorer Mode
Additional Resources
Reference the documentation to find what kind of helpful functions might already be in C#.