Basic Knowledge Series? Ilist←vs→list

Source: Internet
Author: User

Original address →http://www.cnblogs.com/zbphot/archive/2011/11/04/2235933.html
1 IList interface → represents a non-generic collection of objects that can be accessed individually by index. 
12IList implementations have three categories: read-only, fixed-size, variable-size. Read-only IList cannot be modified.  3 fixed-size IList does not allow the addition or removal of elements, but allows the modification of existing elements.  4 variable-size IList allows elements to be added, removed, and modified. --Excerpt from MSDN
-----
There are not too many methods can be convenient and practical, if only as a collection of data bearer, indeed, IList can be competent.
1 list generic class → Represents a strongly typed listing of objects that can be accessed through an index.  2 provides methods for searching, sorting, and manipulating lists.!!! Note: This class is new in the. NET Framework version 2.0. --Excerpt from MSDN

1 the List class is a generic equivalent class of the ArrayList class. This class implements the IList generic interface using an array of size that can be dynamically incremented on demand.  23  List is not guaranteed to be sorted. You must sort the list before performing operations that require the list to be sorted (for example, BinarySearch).  4 You can use an integer index to access the elements in this collection. The index in this collection starts from zero.  5  List accepts null references (nothing in Visual Basic) as valid values for reference types and allows duplicate elements. --Excerpt from MSDN

according to the definition given by MSDN: The obvious point is that * IList<t> is an interface *List<T> is a class, generic class

1 *in the original, I think it's the essence.2IList<>is an interface that defines how these methods are to be implemented on your own,3List<>is a generic class that has implemented the IList<>the methods that are defined4IList IList11=new List ();5List List11=new List ();6 these two lines of code, from the operational point of view, are actually creating an instance of a list object, which means that their operation is not different. 7 only the return value variable type used to hold this operation is different. 8 So, we can understand that these two lines of code are different in purpose. 9List List11=new List ();Ten is to create a list, and you need to use the function of the list to do related operations.  Oneand the IList IList11=new List (); A just want to create an instance of an object based on the interface IList, but this interface is implemented by the list.  -So it just wants to use the functionality provided by the IList interface.

1 interface for loose coupling ... facilitates system maintenance and refactoring ... Optimize system flow ... Encourage the use of interfaces,2 This enables the separation of functionality and specific implementations.

1 When we are all going through the IList and list, note that the data I fetch is between 1~1000, and after repeated testing, the efficiency of IList is really lower. Not to mention the larger amount of data ...

1 suddenly think of the primary school period ... 2 The teacher let us copy the text . 3 Some of the earliest apes were said to be handwritten code on paper ... 4 It's okay to copy the MSDN example, it should be good ... 5 always say more, do less ...

Basic Knowledge Series? Ilist←vs→list

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.