I am using the .Split(',')
method on a string that I know has values delimited by commas and I want those values to be separated and put into a string[]
object. This works great for strings like this:
78,969.82,GW440,
.
But the values start to look different when that second value goes over 1000, like the one found in this example:
79,"1,013.42",GW450,...
.
These values are coming from a spreadsheet control where I use the controls built in ExportToCsv(...)
method and that explains why a formatted version of the actual numerical value.
Question
Is there a way I can get the .Split(',')
method to ignore commas inside of quotes? I don't actually want the value "1,013.42"
to be split up as "1
and 013.42"
.
Any ideas? Thanks!
Update
I really would like to do this without incorporating a 3rd party tool as my use case really doesn't involve many other cases besides this one and even though it is part of my work's solution, having a tool like that incorporated doesn't really benefit anyone at the moment. I was hoping there was something quick to solve this particular use case that I was missing, but now that it is the weekend, I'll see if I can't give one more update to this question on Monday with the solution I eventually come up with. Thank you everyone for you assistance so far, I'll will assess each answer further on Monday.