zoukankan      html  css  js  c++  java
  • C# 集合类(五):SortedList

    SortedList类:表示键/值对的集合,与哈希表类似,区别在于SortedList中的Key数组排好序的。

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    namespace ConsoleApplication1
    {
        
    class Program
        
    {
            
    public static void Main()
            
    {
                SortedList sl 
    = new SortedList();
                sl[
    "c"= 41;
                sl[
    "a"= 42;
                sl[
    "d"= 11;
                sl[
    "b"= 13;

                
    foreach (DictionaryEntry element in sl)
                
    {
                    
    string s = (string)element.Key;
                    
    int i = (int)element.Value;
                    Console.WriteLine(
    "{0},{1}", s, i);
                }

            }

        }

    }


  • 相关阅读:
    HDU-1527 取石子游戏
    HDU-1846 Brave Game
    HDU-1850 Being a Good Boy in Spring Festival
    HDU-2509 Be the Winner
    HDU-1907 John
    HDU-1969 Pie
    HDU-1501 Zipper
    HDU-2289 Cup
    最大子矩阵和
    HDU3466(01背包变种)
  • 原文地址:https://www.cnblogs.com/wf225/p/1038091.html
Copyright © 2011-2022 走看看