C# Read Text File Containing Data Delimited By Tabs

前端 未结 2 887
醉话见心
醉话见心 2020-12-17 18:42

I have some code:

 public static void ReadTextFile()
    {
        string line;

        // Read the file and display it line by line.
        using (StreamR         


        
相关标签:
2条回答
  • 2020-12-17 18:57

    You have white space/tabs like this? "    Hello " ?

    Trim remove white spaces and tabs too

    0 讨论(0)
  • 2020-12-17 19:10

    The problem I have is that once the data has been separated, it still has massive amounts of white space on the left and right sides on random strings in the list (Infact most of them do). I can't trim the string because it only removes white space, and technically this isn't white space.

    It sounds like you have non-tab whitespace characters in your string, as well as being tab delimited.

    Using String.Trim should work fine to remove these extra characters. If, for some reason, doing String.Trim on each word is not working, you'll need to switch to find out what the extra "characters" are comprised of, and using this overload of String.Trim.

    0 讨论(0)
提交回复
热议问题