Display List in textBox (Winforms)

前端 未结 5 1779
情歌与酒
情歌与酒 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:34

    You need to concatenate the strings somehow, like

    public string displayMembers(List vegetables)
    {
        return string.Join(", ", vegetables.ToArray());
    }
    

    or

    public string displayMembers(List vegetables)
    {
        return string.Join(Environment.NewLine, vegetables.ToArray());
    }
    

提交回复
热议问题