当前位置: 首页>>代码示例>>C#>>正文


C# SortedList.ToList方法代码示例

本文整理汇总了C#中SortedList.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.ToList方法的具体用法?C# SortedList.ToList怎么用?C# SortedList.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortedList的用法示例。


在下文中一共展示了SortedList.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ListProc

 private void ListProc()
 {
     listView1.Items.Clear();
     Process[] proc = System.Diagnostics.Process.GetProcesses();
     List<Process> l = proc.ToList<Process>();
     SortedList<String, Process> sl = new SortedList<string, Process>();
     int it = 0;
     foreach (Process p in proc)
     {
         if (sl.ContainsKey(p.ProcessName))
             sl.Add(p.ProcessName + it.ToString(), p);
         else sl.Add(p.ProcessName, p);
         it++;
     }
     foreach (KeyValuePair<String, Process> pr in sl.ToList<KeyValuePair<String, Process>>())
     {
         ListViewItem lvi = new ListViewItem(pr.Value.ProcessName);
         lvi.SubItems.Add(pr.Value.BasePriority.ToString());
         lvi.SubItems.Add(pr.Value.Id.ToString());
         lvi.SubItems.Add(pr.Value.WorkingSet64.ToString());
         listView1.Items.Add(lvi);
     }
     toolStripStatusLabel1.Text = "Процессов: " + proc.Count<Process>().ToString();
     int count = 0;
     foreach (Process p in proc)
     {
         count += p.Threads.Count;
     }
     toolStripStatusLabel2.Text = "Потоков: " + count.ToString();
 }
开发者ID:evgenij1204,项目名称:TaskManager,代码行数:30,代码来源:Form1.cs

示例2: GetIndex

        /// <summary>
        /// The index is a collection of the words used for the autocomplete text search, and their associated Ids
        /// </summary>
        /// <param name="datatypeDefinitionId"></param>
        /// <returns></returns>
        private static List<KeyValuePair<string, int>> GetIndex(int datatypeDefinitionId)
        {
            // a sorted list is used for populated, so that it's quick to find duplicates when adding items, and this can be converted to a List for returning (so that a binary search can be used)
            SortedList<string, int> index = new SortedList<string, int>();

            // get the options so we know how to retrieve the data
            XPathAutoCompleteOptions options = XPathAutoCompleteBase.GetOptions(datatypeDefinitionId);

            switch (options.UmbracoObjectType)
            {
                case uQuery.UmbracoObjectType.Document:

                    foreach (KeyValuePair<string, int> keyValuePair in uQuery.GetNodesByXPath(options.XPath).Select(x => new KeyValuePair<string, int>(x.Name, x.Id)))
                    {
                        XPathAutoCompleteBase.AddToSortedList(ref index, keyValuePair);
                    }

                    break;

                case uQuery.UmbracoObjectType.Media:

                    foreach (KeyValuePair<string, int> keyValuePair in uQuery.GetMediaByXPath(options.XPath).Select(x => new KeyValuePair<string, int>(x.Text, x.Id)))
                    {
                        XPathAutoCompleteBase.AddToSortedList(ref index, keyValuePair);
                    }

                    break;

                case uQuery.UmbracoObjectType.Member:

                    foreach (KeyValuePair<string, int> keyValuePair in uQuery.GetMembersByXPath(options.XPath).Select(x => new KeyValuePair<string, int>(x.Text, x.Id)))
                    {
                        XPathAutoCompleteBase.AddToSortedList(ref index, keyValuePair);
                    }

                    break;
            }

            // convert the SortedList into a regular list, and store that (regular list so that we can do a binary search on it)

            return index.ToList();
        }
开发者ID:bokmadsen,项目名称:uComponents,代码行数:47,代码来源:XPathAutoCompleteBase.cs


注:本文中的SortedList.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。