How do I put the contents of a list in a single MessageBox?

前端 未结 5 1133
陌清茗
陌清茗 2020-12-28 20:19

Basically, I have a list with multiple items in it and I want a single message box to display them all.

The closest I have got is a message box for each item (using

5条回答
  •  时光说笑
    2020-12-28 21:03

    You can also use Stringbuilder:

    StringBuilder builder = new StringBuilder();
    
    
    foreach(string str in list)
    {
        builder.Append(str.ToString()).AppendLine();  
    }           
    
    Messagebox.Show(builder.ToString());
    

    Regards

提交回复
热议问题