jeudi 4 août 2016

Best way to concatenate strings C#

{
   String outputFile = String.Format("{0}\t{1}\t{2}\t{3}\r\n", 
                             x.url, x.company, x.country, x.vendor,);

      if (client.cf.is_cis == true)
      {
         outputFile = String.Format("{0}\r\n",
                             x.cis);
      }

      if (client.cf.is_firmographic == true)
      {
         outputFile = String.Format("{0}\t{1}\r\n",
                             x.revenue, x.employee);
      }

      writerCustomerTxt.Write(outputFile);

I have a set of strings that I am trying to output, but obviously with the code above, the output is being overrided if any of the if statements are true. I believe that string concatenation is the solution to this issue. What would be the most efficient way to do this?

Aucun commentaire:

Enregistrer un commentaire