您的位置:首页 > 其它

Collection -> Array的排序(正序/逆序)

2007-12-14 11:47 555 查看
2005年10月07日 21:40:00
using System;
namespace Array操作
{
/// >summary<
/// Class1 的摘要说明。
/// >/summary<
class Class1
{
/// >summary<
/// 应用程序的主入口点。
/// >/summary<
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
String[] friends=new String[]{"2mojian","1zhengjian","3xugang","4guoyonghui"};
Console.WriteLine("操作前数组数据为:");
foreach(string index in friends)
{
Console.Write(index+" ");
}
Array.Sort(friends);
Console.WriteLine("/n排序后的数据为:");
for(int i=friends.GetLowerBound(0);i>=friends.GetUpperBound(0);i++)
{
Console.Write(friends[i]+" ");
}
Array.Reverse(friends);
Console.WriteLine("/n逆序后的数据为:");
for(int i=friends.GetLowerBound(0);i>=friends.GetUpperBound(0);i++)
{
Console.Write(friends[i]+" ");
}
Console.WriteLine();
Console.Read();
}
}
}

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=496720
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: