Display List in textBox (Winforms)

前端 未结 5 1788
情歌与酒
情歌与酒 2020-12-13 21:02

Noob question... I\'m trying to display a List in a textbox... unfortunately, my code only displays the first element in the list...

    private void Form1_L         


        
5条回答
  •  生来不讨喜
    2020-12-13 21:20

    Use string.Join():

    textbox1.Text = string.Join(" ", vegetables);
    

    The answer was closer and easier than you thought :)

    Note: as mentioned in the comments, this particular function has several overloads added in v4.0 of the .Net framework. If you want to see what is available for earlier versions use the Other Versions dropdown just under the title on the MSDN doco page.

提交回复
热议问题