C# How to split string based on 2 parameters?

后端 未结 2 784
借酒劲吻你
借酒劲吻你 2021-01-29 07:49

I have three string called This_is string1 and This is string2 There_is string3

How to split these 3 strings after \"This_\", \"T

2条回答
  •  我在风中等你
    2021-01-29 08:45

    So you want to split only the first part? You can use the overload of String.Split that allows to specify the count and multiple delimiters:

    str.Split(new[]{' ', '_'}, 2);
    

    So on the first string you get: "This" + "is string1", similar on the others.

提交回复
热议问题