Time for action – understanding ElementAt()

Follow the given steps:

  1. Copy the following as a query to LINQPad:
    Stack<string> tags = new Stack<string>(); tags.Push("<html>"); tags.Push("<body>"); List<string> tagList = new List<string>(); tagList.Add("<html>"); tagList.Add("<body>"); Queue<string> queue = new Queue<string>(); queue.Enqueue("<html>"); queue.Enqueue("<body>"); LinkedList<string> linkedTags = new LinkedList<string>(); linkedTags.AddLast("<html>"); linkedTags.AddLast("<body>"); string lastStackTag = tags.ElementAt(tags.Count - 1); string lastListTag = tagList.ElementAt(tagList.Count - 1); string lastQueueTag = queue.ElementAt(queue.Count - 1); string lastLinkedListTag = linkedTags.ElementAt(linkedTags.Count - 1); lastStackTag.Dump("Last ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.