zoukankan      html  css  js  c++  java
  • 排序列表

        排序列表用SortedList对象表示,用Add()方法会自动将元素插入到适当的位置以保持关键字的顺序

    /*
      Example11_8.cs illustrates the use of a SortedList
    */
    
    using System;
    using System.Collections;
    
    class Example11_8
    {
    
      public static void Main()
      {
    
        // create a SortedList object
        SortedList mySortedList = new SortedList();
    
        // add elements containing US state abbreviations and state
        // names to mySortedList using the Add() method
        mySortedList.Add("NY", "New York");
        mySortedList.Add("FL", "Florida");
        mySortedList.Add("AL", "Alabama");
        mySortedList.Add("WY", "Wyoming");
        mySortedList.Add("CA", "California");
    
        // get the state name value for "CA"
        string myState = (string) mySortedList["CA"];
        Console.WriteLine("myState = " + myState);
    
        // get the state name value at index 3 using the GetByIndex() method
        string anotherState = (string) mySortedList.GetByIndex(3);
        Console.WriteLine("anotherState = " + anotherState);
    
        // display the keys for mySortedList using the Keys property
        foreach (string myKey in mySortedList.Keys)
        {
          Console.WriteLine("myKey = " + myKey);
        }
    
        // display the values for mySortedList using the Values property
        foreach(string myValue in mySortedList.Values)
        {
          Console.WriteLine("myValue = " + myValue);
        }
    
      }
    
    }
    
  • 相关阅读:
    error: declaration of 'cv::Mat R ' shadows a parameter
    Java网络编程(二)
    排序算法(二)
    Java网络编程(一)
    排序算法(一)
    Python文件访问模式
    Python文件与异常
    递归
    SQL命令的六个主要类别
    iOS-生成Bundle包-引入bundle-使用bundle
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2039424.html
Copyright © 2011-2022 走看看