using System.IO;
using System.Text;

public void WriteToCsv(string filePath, string[,] data)
{
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < data.GetLength(0); i++)
    {
        for (int j = 0; j < data.GetLength(1); j++)
        {
            sb.Append(data[i, j] + ",");
        }
        sb.Remove(sb.Length - 1, 1);
        sb.AppendLine();
    }

    using (StreamWriter writer = new StreamWriter(filePath))
    {
        writer.Write(sb.ToString());
    }
}