Splitting a String into only 2 parts

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

    char[] delimiterChars = { ' ', ',' };
    string text = txtString.Text;
    
    string[] words = text.Split(delimiterChars, 2);
    
    txtString1.Text = words[0].ToString();
    txtString2.Text = words[1].ToString();
    

提交回复
热议问题