using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace cch
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void textBox4_TextChanged(object sender, EventArgs e)
        {        }        private void btn1_Click(object sender, EventArgs e)
        {
            int m = 0;            
            TextBox[] p = new TextBox[] {tb1,tb2,tb3,tb4,tb5,tb6 };            
            int i;
            for (i = 0; i < 6; i++)
            {
                                if (p[i].Text!="")
                {
                    
                    m++;
                    
                   
                }
            }
            string a = string.Format("你选择了红球{0}个,号码分别是{1}", m);
            lb8.Text = a;
        }
    }
}
我想把p[i].Text的值读出来,放在“号码分别是{1}”, 该怎么做?

解决方案 »

  1.   

    string a = string.Format("你选择了红球{0}个,号码分别是{1}", p[m].Text); 
      

  2.   


    string.Format("你选择了红球{0}个,号码分别是{1}",m, p[m].Text); 
      

  3.   

    int m = 0;            string s = "";
                TextBox[] p = new TextBox[] {tb1,tb2,tb3,tb4,tb5,tb6 };             
                int i; 
                for (i = 0; i < 6; i++) 
                { 
                                    if (p[i].Text!="") 
                    { 
                        
                        m++;                    s += p[i].Text + ";";
                    } 
                }
                string a = string.Format("你选择了红球{0}个,号码分别是{1}", m,s); 
                lb8.Text = a; 搞彩票吗?
      

  4.   

                
                int m = 0; 
                string s = ""; 
                TextBox[] p = new TextBox[] {tb1,tb2,tb3,tb4,tb5,tb6 };           
                int i; 
                for (i = 0; i < TextBox.Length; i++) 
                { 
                                    if (p[i].Text!="") 
                    { 
                        
                        m++;                     s += p[i].Text + ";"; 
                    } 
                } 
                string a = string.Format("你选择了红球{0}个,号码分别是{1}", m,s); 
                lb8.Text = a;