Well I have export to CSV script.
I export list of struct. I write with help of StringWriter. In struct field array foreach cycle I iterate through all properties and after every property I put ‘;’. In the end of line I put WriteLine().
So as output I have:
value1;value2;value3;
And I want:
value1;value2;value3
The question is : how to get what I want from what I get, or based on what I’v already made.
I have 3 ideas right now:
- The last 2 symbols in line should be something like “;\r(\n)” So replace this combination with nothing.
- Check if the property is last.
- Trim last(before newline) symbol in each row.
Use String.Join to form each line for your output. It prevents you from having to check which term is last.
http://msdn.microsoft.com/en-us/library/57a79xd0.aspx
line will be