Split String in C#

前端 未结 9 1005
萌比男神i
萌比男神i 2020-12-28 09:10

I thought this will be trivial but I can\'t get this to work.

Assume a line in a CSV file: \"Barack Obama\", 48, \"President\", \"1600 Penn Ave, Washington DC

9条回答
  •  醉话见心
    2020-12-28 09:55

    You should be using Microsoft.VisualBasic.FileIO.TextFieldParser for that. It will handle all the CSV stuff correctly for you, see: A similar question with example using the TextFieldParser

    PS: Do not fear using the Microsoft.VisualBasic dll in a C# project, it's all .NET :-)

提交回复
热议问题