比如:文本有3行
aa
bb
cc
我是打算用一个STRING数组的k[0]=aa,k[1]=bb,k[2]=cc,怎么写呢

解决方案 »

  1.   

    这个用List会好一点,读一行存一行就行了
      

  2.   

    LIST我找了下资料,遇到个问题,比如我要读bb出来怎么写呢?list很不熟
      

  3.   

    你所说的文本是文本文件还是控件里的文本啊?
    文本文件里的内容可用StreamReader类
    StreamReader streamFile=new StreamReader();
    while (streamFile.Peek()>=0)
    {
    str=streamFile.ReadLine();
    }
      

  4.   


    using System.Collections;            ArrayList arrList = new ArrayList();
                arrList.Add("a");
                arrList.Add("b");            arrList[1].ToString()  //"b"
    或者用泛型也行List<T>,但是开始比较麻烦点,定义好了,使用起来比较方便
      

  5.   

    问题解决,方法如下:
     private void button5_Click(object sender, EventArgs e)
            {
                string[] kk = ReadTxt(Application.StartupPath + "\\update.ini");
                label9.Text = kk[0];
                label10.Text = kk[1];
            }
            public string[] ReadTxt(string sPath)//读INI
            {
                string[] txt = new string[3];
              StreamReader sr = new StreamReader(sPath, Encoding.GetEncoding("GB2312"));
                txt[0] =sr.ReadLine();
                txt[1] =sr.ReadLine();
                sr.Close();
                return txt;
            }
      

  6.   

    如果不是3行,你的程序不是有问题?还是用List和循环较好