using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
namespace hello
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Array.Sort();";
ArrayList arrData = new ArrayList();
string strPath = @"E:\\Test.txt";
arrData = Read(strPath);
Console.WriteLine("读取文件内容为:");
foreach (object o in arrData)
{
Console.WriteLine(o.ToString());
}
Console.WriteLine("数据排序后的内容为:");
arrData.Sort();
foreach (object o in arrData)
{
Console.WriteLine(o.ToString());
}
Console.ReadKey();
}
static ArrayList Read(string path)
{
try
{
ArrayList arr = new ArrayList();
StreamReader sr = new StreamReader(path, Encoding.Default);
string strLine = null;
while ((strLine = sr.ReadLine()) != null)
{
arr.Add(strLine);
}
return arr;
}
catch (Exception e)
{
throw e;
}
}
}
}
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
namespace hello
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Array.Sort();";
ArrayList arrData = new ArrayList();
string strPath = @"E:\\Test.txt";
arrData = Read(strPath);
Console.WriteLine("读取文件内容为:");
foreach (object o in arrData)
{
Console.WriteLine(o.ToString());
}
Console.WriteLine("数据排序后的内容为:");
arrData.Sort();
foreach (object o in arrData)
{
Console.WriteLine(o.ToString());
}
Console.ReadKey();
}
static ArrayList Read(string path)
{
try
{
ArrayList arr = new ArrayList();
StreamReader sr = new StreamReader(path, Encoding.Default);
string strLine = null;
while ((strLine = sr.ReadLine()) != null)
{
arr.Add(strLine);
}
return arr;
}
catch (Exception e)
{
throw e;
}
}
}
}