Create comma separated strings C#?

前端 未结 5 1529
走了就别回头了
走了就别回头了 2020-12-09 01:22

I have an object which holds many values, some of them (not all values from the object) need to be put in a csv string. My approach was this:

string csvStrin         


        
5条回答
  •  渐次进展
    2020-12-09 02:01

    You could override your object's ToString() method:

    public override string ToString ()
    {
        return string.Format ("{0},{1},{2}", this.number, this.id, this.whatever);
    }
    

提交回复
热议问题