c# - What's the implementation of List? -


i read code:

list<long> useridlist = new list<long>(); 

but jumped definition(use vs2012) of list (in system.collections.generic), found:

public class list<t> : ilist<t>, icollection<t>, ienumerable<t>, ilist, icollection, ienumerable {     // summary:     //     initializes new instance of system.collections.generic.list<t> class     //     empty , has default initial capacity.     [targetedpatchingoptout("performance critical inline across ngen image boundaries")]     public list();     //     // summary:     //     initializes new instance of system.collections.generic.list<t> class     //     contains elements copied specified collection , has sufficient     //     capacity accommodate number of elements copied.     //     // parameters:     //   collection:     //     collection elements copied new list.     //     // exceptions:     //   system.argumentnullexception:     //     collection null.     public list(ienumerable<t> collection);     //     // summary:     //     initializes new instance of system.collections.generic.list<t> class     //     empty , has specified initial capacity.     //     // parameters:     //   capacity:     //     number of elements new list can store.     //     // exceptions:     //   system.argumentoutofrangeexception:     //     capacity less 0.     [targetedpatchingoptout("performance critical inline across ngen image boundaries")]     public list(int capacity);      // summary:     //     gets or sets total number of elements internal data structure can     //     hold without resizing.     //     // returns:     //     number of elements system.collections.generic.list<t> can contain     //     before resizing required.     //     // exceptions:     //   system.argumentoutofrangeexception:     //     system.collections.generic.list<t>.capacity set value less     //     system.collections.generic.list<t>.count.     //     //   system.outofmemoryexception:     //     there not enough memory available on system.     public int capacity { get; set; }     //     // summary:     //     gets number of elements contained in system.collections.generic.list<t>.     //     // returns:     //     number of elements contained in system.collections.generic.list<t>.     public int count { get; }      // summary:     //     gets or sets element @ specified index.     //     // parameters:     //   index:     //     zero-based index of element or set.     //     // returns:     //     element @ specified index.     //     // exceptions:     //   system.argumentoutofrangeexception:     //     index less 0.-or-index equal or greater system.collections.generic.list<t>.count.     public t this[int index] { get; set; }      // summary:     //     adds object end of system.collections.generic.list<t>.     //     // parameters:     //   item:     //     object added end of system.collections.generic.list<t>.     //     value can null reference types.     public void add(t item);      ... 

it's not interface or abstract, doesn't have function body(for method in class). know arraylist , linkedlist, list, have no idea implementation.

my question:

  1. where implementation of list?
  2. if list equals arraylist or something, why .net allow 2 class equals function different name? if list doesn't equal other class in .net, why give such ambiguous name?

msdn states:

the list class generic equivalent of arraylist class. implements ilist generic interface using array size dynamically increased required.

so, think it's bad name...

the implementation of list<t> can't shown visual studio because doesn't have source code present. shows outline of class (that why visual studio puts [metadata] on top of 'code file' when hitting f12).

the actual source can found on referencesource.microsoft.com.

if list equals arraylist or something, why .net allow 2 class equals function different name? if list doesn't equal other class in .net, why give such ambiguous name?

no, not same. arraylist non-generic list implementation, while list<t> is generic, , typed.

regarding ambiguous name: think microsoft right in naming of list. arraylist terrible name anyway. emphasizes implementation much. don't care there array behind it: list. given name available, option name.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -