CSharp examples for System.Collections.Generic:List
Returns the last element of the list.
using System.Collections.Generic; using System;/* w w w . j a va 2 s . c om*/ public class Main{ /// <summary> /// Returns the last element of the list. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <returns></returns> public static T LastItem<T>(this List<T> list) { return list[list.Count - 1]; } }