29
1
using System;
2
using System.Collections.Generic;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
var wordArray = new string[]{"word", "Array"};
9
var wordList = new List<string>{"word", "List"};
10
11
GenericPrintWords(wordArray);
12
13
// divider
14
Console.WriteLine(new string ('*', 30));
15
16
GenericPrintWords(wordList);
17
}
18
19
public static void GenericPrintWords<T>(IEnumerable<T> words)
20
{
21
foreach (var word in words)
22
Console.WriteLine(word);
23
}
24
25
public static void ListPrintWords<T>(List<T> words)
26
{
27
words.ForEach(word => Console.WriteLine(word));
28
}
29
}
Cached Result