<lidata-marpit-fragment="1"><em><strong>Note:</strong></em> You could name the generic type as anything, e.g. <code><GenericType></code>. It is named <code><T></code> by convention.</li>
<h2id="exercise-1-initializing-a-populated-list">Exercise 1: Initializing a populated list</h2>
<p>Create a generic method <code>GetPopulatedList<T></code> which takes two parameters: <code>T value</code> and <code>int length</code>, and returns a new list of type <code>T</code> which is populated with the <code>value</code> variables and has a length of <code>length</code>.</p>
* ***Note:*** You could name the generic type as anything, e.g. `<GenericType>`. It is named `<T>` by convention.
## Exercise 1: Initializing a populated list
<!-- _backgroundColor: #29366f-->
<!-- _class: exercise -->
Create a generic method `GetPopulatedList<T>` which takes two parameters: `T value` and `int length`, and returns a new list of type `T` which is populated with the `value` variables and has a length of `length`.
@ -437,7 +437,7 @@ No error!
## Exercise 2: Filtering Names
<!-- _backgroundColor: #29366f-->
<!-- _class: exercise -->
* Download this file of names and add it to your project folder: [https://raw.githubusercontent.com/dominictarr/random-name/master/names.txt](https://raw.githubusercontent.com/dominictarr/random-name/master/names.txt)
* Read all the contents into a string array with `File.ReadAllLines()`
@ -445,7 +445,7 @@ No error!
* If there are less than 10 resulting names, print the names as well!
## Exercise 3: Queries on Object Lists
<!-- _backgroundColor: #29366f-->
<!-- _class: exercise -->
* Expand on the exercise 2.
* Create a new class User with two properties, int Id and string Name
@ -454,6 +454,7 @@ No error!
* Print the names and id:s of the users in the sorted list
## Going Further: Extension Methods
<!-- _class: extra -->
* Recap: `IEnumerable` itself only contains one method
* How does the LINQ library suddenly add all these methods to our Enumerables?
@ -94,8 +94,7 @@ title: 14. Exceptions, Threads and Tasks
```
## Exercise 1: Debugging Exceptions
<!-- _backgroundColor: #29366f -->
<!-- _class: exercise -->
Create a savings calculator which asks the user for a target amount of money the user is aiming for (in integers), and the users monthly salary. For parsing, use the int.Parse() method instead of int.TryParse().
@ -204,7 +203,7 @@ The method keeps executing indefinitely, but the main thread continues execution
```
## Exercise 2: Threaded Loading
<!-- _backgroundColor: #29366f-->
<!-- _class: exercise -->
Create a method `public static void LoadData()` which simulates loading resources by printing progress from $0 \%$ to $100 \%$. Increase the progress in a loop with $1 \%$ increments. Use the `Thread.Sleep()` method to wait $10\,\mathrm{ms}$ between each increment.
@ -279,7 +278,7 @@ class Program
</div>
## Exercise 3: Asynchronous Loading
<!-- _backgroundColor: #29366f-->
<!-- _class: exercise -->
Re-create the exercise 2, but instead of using separate threads for "loading the data", use an asynchronous method `LoadDataAsync()`