CSV string handling

后端 未结 13 844
北荒
北荒 2020-12-28 16:44

Typical way of creating a CSV string (pseudocode):

  1. Create a CSV container object (like a StringBuilder in C#).
  2. Loop through the strings you want to ad
13条回答
  •  感情败类
    2020-12-28 17:08

    How about some trimming?

    public string ReturnAsCSV(ContactList contactList)
    {
        StringBuilder sb = new StringBuilder();
    
        foreach (Contact c in contactList)
        {
            sb.Append(c.Name + ",");
        }
    
        return sb.ToString().Trim(',');
    }
    

提交回复
热议问题