C # Common data structures

Source: Internet
Author: User

1. Set List: Put data of the same data type into a container, the container is a collection, memory of a series of space. Features: 1), a strongly typed object that can be accessed through an index. 2), is the generic equivalent class of the ArrayList class. 3), you can use an integer index to access the elements in this collection, and the index starts at zero. 4), allow repeating elements. Method of List<t> Collection: 01. Add adds the object to the end of the list<t>. AddRange adds the elements of the specified collection to the end of the list<t>.    The. Clear removes all elements from the list<t>. Contains determines whether an element is in list<t>. Exists Determines whether the list<t> contains elements that match the conditions defined by the specified predicate. 06.  IndexOf (T) searches for the specified object and returns the zero-based index of the first occurrence in the entire list<t>. Insert inserts an element into the list<t> at the specified index. Remove removes the first occurrence of a specific object from the list<t>. The. Sort () uses the default comparer to sort the elements in the entire list<t>. There are two ways to traverse a list<t> collection: for and FOREACH2. Dictionary Dictionary: Features: 1), mappings from a set of keys (key) to a set of values (value), each of which consists of a value and its associated key Any key must be unique, the key cannot be null, and if the value is a reference type, it can be a null value. 2), key, and value can be of any type (String,int,custom class, etc.). Method of Dictionary Dictionary: 01.  Comparer: Gets the iequalitycomparer used to determine whether the keys in the dictionary are equal.  02.Count: Gets the number of key/value pairs contained in the dictionary.  03.Item: Gets or sets the value associated with the specified key.  04.Keys: Gets the collection that contains the keys in the dictionary. 05.ValUEs: Gets the collection that contains the values in the dictionary.  06.ADD: Adds the specified key and value to the dictionary.  07.Clear: Remove all keys and values from the dictionary.  08.ContainsKey: Determines whether the dictionary contains the specified key.               09.ContainsValue: Determines whether the dictionary contains a specific value.  10.GetEnumerator: Returns an enumerator that iterates through the dictionary. 11.GetType: Gets the Type of the current instance. (Inherit from Object.)  12.Remove: Removes the value of the specified key from the dictionary. 13.ToString: Returns a String that represents the current object. (Inherit from Object.) 14.TryGetValue: Gets the value associated with the specified key. 3. Queues Queue definition mode:queue<t> queue = new queue<t> (); feature: FIFO queue method: 01.Clear: Empty queue 02. Contains: Determines whether an element is in the queue 03. Dequeue: Removes and returns an object at the beginning of the Queue. 04.Enqueue: Adds an object to the end of the Queue. 4. Stack stack definition mode:stack<t> stack = new stack<t> (); Feature: Method of last-in-first stack stack: 01.Pop Remove and return object 02.push to Sta at top of stack The top of the CK adds an object 03.peek returns the object at the top of the stack, but does not remove it 04.ToArray creates an array and copies the stack elements into which 05.Contains determines whether an element is in the stack 06.Clear from the stack Except for all the elements.

  

C # Common data structures

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.