Splitting a String into only 2 parts

前端 未结 5 1111
抹茶落季
抹茶落季 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:28

    Use String.Split(Char[], Int32) overload like this:

    string[] array = txtFrom.Text.Split(new char[]{' '},2);
    

    http://msdn.microsoft.com/en-us/library/c1bs0eda.aspx

提交回复
热议问题