日期:2014-05-17  浏览次数:20436 次

请教 关于list.sort()参数的问题。分少见谅,在线等回复。
<script runat="Server">
        private List<string> rowrow = new List<string>();
        void Page_Load(object sender, EventArgs e)
        { 
            rowrow.Add("minke");
            rowrow.Add("heke");
            rowrow.Add("wangdong");
            rowrow.Add("dami");
            rowrow.Add("xixi");
        }
        protected void sort_command(object sender,CommandEventArgs e)
       {
            if (e.CommandName=="sort")
            {
                switch(e.CommandArgument.ToString())
                {
                    case "ASC":
                        rowrow.Sort(SortASC);
                        break;
                    case "DESC":
                        rowrow.Sort(SortDESC);
                          break;
                    
                }
            }
      
       }
        void Page_PreRender(object sender, EventArgs e)
        {
            bulletedlist1.DataSource = rowrow;
            bulletedlist1.DataBind();
        }
        int SortASC(string x, string y)
        {
            return string.Compare(x, y);
        
        }
        int SortDESC(string x,string y)
        {
          &