Splitting a String into only 2 parts

前端 未结 5 1177
抹茶落季
抹茶落季 2021-02-07 21:52

I want to take a string from a textbox (txtFrom) and save the first word and save whatever is left in another part. (the whatever is left is everything past the first space)

5条回答
  •  野的像风
    2021-02-07 22:20

    There is an overload of the String.Split() method which takes an integer representing the number of substrings to return.

    So your method call would become: string[] array = txtFrom.Text.Split(' ', 2);

提交回复
热议问题