Array.Join in .Net?

后端 未结 7 802
挽巷
挽巷 2020-12-10 10:26

Ok, this is a dumb thing that I\'m sure I\'ve done dozens of times but for some reason I can\'t find it.

I have an array... And want to get a string with the content

相关标签:
7条回答
  • 2020-12-10 11:26

    You can find the method in the String class.

    Example using Split and Join:

     public static void Main() { 
    
        string str = "on two three, four five six."; 
        char[] separators = {' ', '.', ',' }; 
    
        // Split the string:
        string[] parts = str.Split(separators); 
    
        string allTogether = String.Join(" | ", parts); 
    
        Console.WriteLine("Joined: "); 
        Console.WriteLine(allTogether); 
    
    
      } 
    
    0 讨论(0)
提交回复
热议问题