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);
私は出力しようとしている文字列がありますが、明らかに上記のコードではif文のいずれかが真であれば出力が上書きされています。私は文字列連結がこの問題の解決策であると信じています。これを行う最も効率的な方法は何でしょうか?文字列を連結する最適な方法
[StringBuilder](https://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v = vs.110).aspx)を使用して、[docs](http: //stackoverflow.com/documentation/c%23/4675/stringbuilder#t=201608042040323782465) – DavidG
コードに連結がありません。 –
@DavidG:指定されたコードサンプルに対してStringBuilderを使用する理由はありません。 – StriplingWarrior