CSharp examples for System.Collections:IEnumerable
Print elements in format 'element, element, element, ...'
using System.Text; using System.Linq; using System.Collections.Generic; using System;// w w w . ja va 2s. c om public class Main{ /// <summary> /// Print elements in format 'element, element, element, ...' /// </summary> /// <param name="array"></param> /// <returns></returns> public static string PrintArray(this System.Collections.IEnumerable array) { if (array == null) { return string.Empty; } StringBuilder builder = new StringBuilder(); foreach (var item in array) { builder.Append(item); builder.Append(", "); } return builder.ToString(); } }