The best overloaded method match for 'string.Join(string, string[])' has some invalid arguments

前端 未结 4 1134
独厮守ぢ
独厮守ぢ 2021-01-22 07:29

I want to extract come text between two tags. The \"txtReadfile\" contains many tags. I want to extract all the text in each occurrence of the tag.

I used the following

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 08:06

    Before .NET 4, the String.Join method only had overloads that took arrays as their second parameter. Support for IEnumerable was only introduced in .NET 4.0.

    // From .NET 2.0:
    Join(String, String[])
    Join(String, String[], Int32, Int32)
    Join(String, Object[])
    
    // From .NET 4.0:
    Join(String, IEnumerable)
    Join(String, IEnumerable)
    

    Thus, if you're targeting an earlier framework, you need to call ToArray on your list to convert it into string[]:

    string output= string.Join(" ", destList.ToArray());
    

提交回复
热议问题