zoukankan      html  css  js  c++  java
  • C#集合

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using static System.Console;
    
    //集合
    
    namespace lwm
    {
        class Program
        {
            static void Main()
            {
                //1.列表 容量0 -> 4 -> 8 ->16
                var intList = new List<int>();
                intList.Capacity = 20;
                //WriteLine(intList.Count);
                intList.TrimExcess();
    
                intList.Add(1);
                intList.AddRange(new int[]{2,3,4});
                
                for (int i = 0; i < intList.Count; ++i)
                {
                    WriteLine(intList[i]);
                }
    
                WriteLine();
    
                intList.RemoveAt(0);
                intList.Remove(3);
    
                foreach (var i in intList)
                {
                    WriteLine(i);
                }
    
                intList.IndexOf(4);
    
                intList.Sort();
    
                //2.队列
                var q = new Queue<double>();
    
                //3.栈
                var s = new Stack<double>();
    
                //4.双向链表
                var linkList = new LinkedList<int>();
    
                //5.有序列表 基于键排序 //元素类型KeyValuePair<TKey, TValue>
                var sList = new SortedList<int, string>();
    
                foreach (int i in sList.Keys)
                { }
                foreach (string s1 in sList.Values)
                { }
    
                //6.字典
                var dict = new Dictionary<int, string>();
                var sdict = new SortedDictionary<int, string>();
    
                //7.集 不能重复
                var hset = new HashSet<int>();
                var sset = new SortedSet<int>();
    
    
            }
    
        }
    
    }

  • 相关阅读:
    MySQL数据类型
    Linux网络编程:客户端/服务器的简单实现
    初学JAVA
    依据函数名字符串执行函数
    Windows Server 2012学习文档
    DELPHI WEBSERVICE
    常用函数、常量、类型记录
    CAD2007_DWG转PDF
    MCU_头文件编写
    MCU_存储器
  • 原文地址:https://www.cnblogs.com/xslwm/p/9857031.html
Copyright © 2011-2022 走看看