我是新手 ,用C#做了个 读入文本中的数据并冒泡排序的 小程序 ,请大虾帮忙修改下:
文本中可以有多种情况:
 比如   文本中可以是这样的:
1,2,5,8,     9
,7     ,6
,,10 
请问在什么情况下  strAll.Length-1  什么情况下 strAll.Length-2 
帮忙把代码修改下  谢谢!!!
 代码如下:
using System;
using System.IO;
using System.Text;
namespace ConsoleApplication2
{
    /// <summary>
    /// Summary description for Class2.
    /// </summary>
    public class Class1
    {  
        public  static void Main(string[] args)
        {
            ////读入并存到一个数组中
            string delimiter = ",";
            string strFile = @"c:\source.txt";
            StreamReader s = new StreamReader(strFile,Encoding.Default);
string strAll = s.ReadToEnd();
            strAll = strAll.Substring(0,strAll.Length-2);
            strAll = strAll.Replace("\n","");
            string[] rows = strAll.Split("\t".ToCharArray());
            foreach(string r in rows)
            {
                string[] items = r.Split(delimiter.ToCharArray());
                int size = items.Length;
                int[] temp = new int[size];
 
                for(int i=0;i< items.Length;i++)
                {
                    temp[i] = Int32.Parse(items[i]);
                }
                Sort(temp,temp.Length);
                Console.ReadLine();
            }
        }
//冒泡
        public static  void Sort(int[] list,int index)
        {
            int i,j,s;
            for(i=index;i>0;i--)
            {
                for(j=0;j<i-1;j++)
                {
                    if(list[j]>list[j+1])
                    {
                        s = list[j+1];
                        list[j+1] = list[j];
                        list[j] = s;
                    }
                }
            }
            Console.WriteLine("排序结果:");
            for(i=0;i<index;i++)
            {
                Console.Write("{0} ",list[i]);
            }
    
        }
}
}



 
											





 
	    

 
	
