zoukankan      html  css  js  c++  java
  • List<t>中如何将指定元素的值放到第一位

            public static List<GCountryExtend> GetList()
            {
                try
                {
                    var result = new List<GCountryExtend>();
                    using (ServiceManager<IGCountry> sm = new ServiceManager<IGCountry>())
                    {
                        result = sm.Service.GetExtendListByWhere(string.Empty);
                        //处理中国优先在第一位
                        if (result.ExistsData() && result.Count>1)
                        {
                            var index = result.FindIndex(x=>x.CountryNameL=="中國");
                            if (index>0)
                            {
                                var firstCountry = result[0];
                                var china = result[index];
                                result[index] = firstCountry;
                                result[0] = china;
                            }
                           
                        }
                    }
                    return result;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
    

      

  • 相关阅读:
    javascript 冒泡
    js闭包
    loadmore & scroll
    viewport
    担当
    javascript pattern
    javascript function
    interview
    json and .net
    java sqlserver
  • 原文地址:https://www.cnblogs.com/benbenfishfish/p/6143849.html
Copyright © 2011-2022 走看看