convert string array to string

后端 未结 9 2173
野性不改
野性不改 2020-12-02 10:59

I would like to convert a string array to a single string.

string[] test = new string[2];
test[0] = \"Hello \";
test[1] = \"World!\";

I wou

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 11:23

    A slightly faster option than using the already mentioned use of the Join() method is the Concat() method. It doesn't require an empty delimiter parameter as Join() does. Example:

    string[] test = new string[2];
    test[0] = "Hello ";
    test[1] = "World!";
    
    string result = String.Concat(test);
    

    hence it is likely faster.

提交回复
热议问题