To Joined Csv string - CSharp System.IO

CSharp examples for System.IO:CSV File

Description

To Joined Csv string

Demo Code

// Permission is hereby granted, free of charge, to any person obtaining a copy
using System.Collections.Generic;
using System;//from   w w  w . j  a v  a 2 s .  c o m

public class Main{
        public static string ToJoined(params string[] csv)
    {
      if (csv.Length == 0)
        return string.Empty;

      return string.Join(",", Array.ConvertAll(csv, delegate(string s) {
        if (s.Contains("\""))
          return string.Format("\"{0}\"", s.Replace("\"", "\"\""));
        else
          return s;
      }));
    }
}

Related Tutorials