c# 中怎样把ListBox中的所有项循环提取出来赋给一个变量!我将一个数据库中的所有表名显示到一个ListBox中,但每次只需要取出一张表,可又要全部取完,不能重复取也不能少取!我想把里面的表名循环提取出来赋给一个变量,可不知道怎么弄?高手帮下忙!!!!

解决方案 »

  1.   

    你用foreach循环呀,循环遍历ListBox的Items嘛。
    然后可以用累加:比如一个变量,string table += item.ToString();
      

  2.   

    foreach (string itemValue in listBox1.Items)
    {
        string csdn += itemValue;

    //winform这样
      

  3.   

                string tableString=null;
                
                foreach (string s in listBox1.Items)
                {
                    tableString += s;
                }