Exercise 1: Initializing a populated list
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
.
Test your method out with a couple of different types and lengths:
List<string> list = GetPopulatedList<string>("Hello, there", 10);
foreach(string value in list)
{
Console.WriteLine(value);
}