List To String : Generic Collections « Generics « C# / C Sharp






List To String

   


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

public static class CollectionsExtensions
{
    public static string ToStringAll<T>(this List<T> list)
    {
        StringBuilder sb = new StringBuilder();
        foreach (var item in list)
        {
            sb.Append(item.ToString());
            sb.Append(Environment.NewLine);
        }

        return sb.ToString();
    }


}

   
    
    
  








Related examples in the same category

1.Generic Collection and List
2.Add user-defined object to generic Collection
3.Add Collection Items with IComparable interface implementation
4.Sort by Name
5.Add object in a hierarchy into a generic Collection
6.Generic collection class
7.Represents a generic collection of key/value pairs. The enumerator returns the values in the order assigned.
8.Convert Dictionary to String
9.String list and String set