public void CreatingCsvFiles(Client client)
{
string filePath = "Your path of the location" + "filename.csv";
if (!File.Exists(filePath))
{
File.Create(filePath).Close();
}
string delimiter = ",";
string[][] output = new string[][]{
new string[]{ "=\"" + client.phone + "\"", client.name }
};
int length = output.GetLength(0);
StringBuilder sb = new StringBuilder();
for (int index = 0; index < length; index++)
sb.AppendLine(string.Join(delimiter, output[index]));
File.AppendAllText(filePath, sb.ToString());
}
http://softwaretipz.com/c-sharp-code-to-create-a-csv-file-and-write-data-into-it/に触発されました
重要な部分:
"=\"" + client.phone + "\"", client.name
電話番号が int の場合は、もちろん .toString() を追加します。