PrintWords

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var wordArray = new string[]{"word", "Array"};
		var wordList = new List<string>{"word", "List"};
		
		GenericPrintWords(wordArray);
		
		// divider
		Console.WriteLine(new string ('*', 30));
		
		GenericPrintWords(wordList);
	}

	public static void GenericPrintWords<T>(IEnumerable<T> words)
	{
		foreach (var word in words)
			Console.WriteLine(word);
	}

	public static void ListPrintWords<T>(List<T> words)
	{
		words.ForEach(word => Console.WriteLine(word));
	}
}
;