• Unity C#集合


    集合分为两种:非泛型集合,泛型集合。

    非泛型集合需要引入:System.Collections命名空间,其命名空间下的类有:

    ArrayList表示大小根据需要动态增加的对象数组。

    Hashtable表示根据键的哈希代码进行组织的键/值对的集合。

    Queue表示对象的先进先出(FIFO)集合。

    Stack表示对象的后进先出(LIFO)集合。

    Stack  stack=new  Stack();

    Stack<int>  stack=new  Stack<int>();

    泛型集合需要引入:System.Collection.Generic命名空间,其命名空间下的类有:

    Dictionary<TKey,TValue>表示根据键进行组织的键/值对的集合。

    Dictionary<string,int>  dic=new  Dictionary<string,int>();

    List<T>表示可根据索引访问对象的列表。提供用于对列表进行搜索,排序和修改的方法

    Queue<T>表示对象的先进先出集合

    SortedList<TKye,TValue>

    表示根据键进行排序的键/值对的集合,而键基于的是相关 IComparer<T>实现

    Stack<T>表示对象的后进先出集合

    我要……

    泛型集合选项

    非泛型集合选项

    线程安全或不可变集合选项

    将项存储为键/值对以通过键进行快速查找

    Dictionary<TKey, TValue>

    Hashtable 

    (根据键的哈希代码组织的键/值对的集合。)

    System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>

    System.Collections.ObjectModel.ReadOnlyDictionary<TKey, TValue>

    ImmutableDictionary(TKey, TValue)

    按索引访问项

    List<T>

    System.Array

    System.Collections.ArrayList

    ImmutableList(T)

    ImmutableArray

    使用项先进先出 (FIFO)

    Queue<T>

    Queue

    System.Collections.Concurrent.ConcurrentQueue<T>

    ImmutableQueue(T)

    使用数据后进先出 (LIFO)

    Stack<T>

    Stack

    System.Collections.Concurrent.ConcurrentStack<T>

    ImmutableStack(T)

    按顺序访问项

    LinkedList<T>

    无建议

    无建议

    删除集合中的项或向集合添加项时接收通知。 (实现 INotifyPropertyChanged 和 System.Collections.Specialized.INotifyCollectionChanged)

    System.Collections.ObjectModel.ObservableCollection<T>

    无建议

    无建议

    已排序的集合

    System.Collections.Generic.SortedList<TKey, TValue>

    System.Collections.SortedList

    ImmutableSortedDictionary(TKey, TValue)

    ImmutableSortedSet(T)

    数学函数的一个集

    System.Collections.Generic.HashSet<T>

    System.Collections.Generic.SortedSet<T>

    无建议

    ImmutableHashSet(T)

    ImmutableSortedSet(T)

  • 相关阅读:
    P1541 乌龟棋
    P1725 琪露诺
    P1622 释放囚犯
    P1417 烹调方案
    积木大赛
    换教室
    C#文件和目录的操作
    C#应用程序所有已经打开的窗体的集合
    C#winform自定义滚动条
    C#ADO.NET基础二
  • 原文地址:https://www.cnblogs.com/Jason-c/p/6656113.html
Copyright © 2020-2023  润新知