CSharp examples for LINQ:IEnumerable
Pass array as IEnumerable parameter
using System;/*from www .j a va2 s. c o m*/ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using static System.Console; using static System.Diagnostics.Process; class Program { static void Main(string[] args) { var test1 = new string[] { "A", "B", "C", "D" }; var test2 = new string[] { "Jack", "S", "X", "Jack", "Z" }; var test3 = new string[] { "D", "Jack", "Jack", "G", "Conor" }; Output(test1, "Test 1"); Output(test2, "Test 2"); Output(test3, "Test 3"); } private static void Output(IEnumerable<string> test, string description = "") { if (!string.IsNullOrEmpty(description)) { WriteLine(description); } Write(" "); WriteLine(string.Join(", ", test.ToArray())); } }