Several common functions of the List<t> class "Unity practical Skills"

Source: Internet
Author: User

The list<t> in C # itself provides a lot of interfaces to make your code very neat. A lot of me also see from the code written by other programmers in the project, learn to record a bit ~

The details of course are to go to the official Help document: Https://msdn.microsoft.com/zh-cn/library/6sh2ey19 (v=vs.110). aspx


The simplest few add,clear,contain will not say more, speak a few useful:


    1. Sorts sort ().

      This has been specifically said before, can look this way: http://blog.51cto.com/13638120/2084838

    2. Reverse order reverse ().

This is to flip the list order, generally with sort

3.ToArray ()

Transfer to a group, commonly used

4.Select ()

This is to get the data from the original list and project it into a new listing, which can be a parameter in the original table, and the two-list T doesn't have to be always, like

Class a{float b;} list<a> list = new list<a> (); list<b> NewList = list. Select (a = A.B);

4.Max ()

Returns the maximum value of the list, if T is a numeric value

5.Average ()

Returns the average of the data in the list, if T is a numeric value.



...

Welcome to Supplement

Several common functions of the List<t> class "Unity practical Skills"

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.