[Reserved] List collection in C # using the First () method to get the first element

During operation of the set of List C #, if the object is to get the first element of a List collection is typically the first element to be acquired by acquiring the list [0] in this way. In fact, provides First () method, this method is called the collection available List first element of direct access to the last element in the List collection.

For example, a List <int> set of objects List1, needs to acquire the collection of objects to the first element may be used First () method, as follows:

  List<int> list1 = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

 var firstInt=list1.First();

Note: The text reproduced from personal bloggers station IT technology small fun house , the original link in C # List collection to use First () method to get the first element _IT technology small fun house .

Guess you like

Origin www.cnblogs.com/xu-yi/p/10993483.html