c# parsing
-
Friday, January 04, 2013 6:42 PMhello, just checking if anyone knows a simple way to parse out the following in c# before i try to hack up some ugly code to manually do this:
"A", "B", "C"
into A, B, C.... A, B, C are strings that can have a comma in it.
All Replies
-
Friday, January 04, 2013 6:47 PM
Tell me if I am wrong, but if you want to to make a very simple string that hold all values + comma you can do it in this way which is most simple:
string a = "A"; string b = "B"; string c = "C"; string comma = ","; string print = a + comma + b + comma + c; Console.WriteLine(print);
Microsoft Student Parnter Microsoft Technology Associate
-
Friday, January 04, 2013 7:07 PMModerator
If this is in a CSV file, you can use the TextFieldParser class to do this: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser.aspx
This class is built in, and handles nested commas within your quoted strings, etc.
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Proposed As Answer by servy42Microsoft Community Contributor Friday, January 04, 2013 7:37 PM
- Marked As Answer by Nehemiah Willis Monday, January 07, 2013 6:16 PM
-
Saturday, January 05, 2013 3:36 AM
Willis :
Does this help with parsing ?
string[] arr = { "A", "B", "C" }; var result = new String(string.Join(",",arr).ToCharArray()); Console.WriteLine(result);
-
Monday, January 07, 2013 6:20 PM
thanks Reed, TextFieldParser class worked.
@Venkat786, I'm trying to split out a comma separated, quoted fields, not join them them back together. I tried doing split but it messes up if a field has a comma within.

