C# Programming - Generics - Discussion

Discussion Forum : Generics - General Questions (Q.No. 1)
1.
Which one of the following classes are present System.Collections.Generic namespace?
  1. Stack
  2. Tree
  3. SortedDictionary
  4. SortedArray
1 and 2 only
2 and 4 only
1 and 3 only
All of the above
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Ishwar Patil said:   7 years ago
Stack is non-generic.

K2u2007 said:   9 years ago
Dictionary<TKey, TValue>: Stores key/value pairs. Provides functionality similar to that found in the non-generic Hashtable class.

HashSet<T>: Stores a set of unique values using a hash table.

LinkedList<T>: Stores elements in a doubly linked list.

List<T>: A dynamic array. Provides functionality similar to that found in the non-generic ArrayList class.

Queue<T>: A first-in, first-out list. Provides functionality similar to that found in the non-generic Queue class.

SortedDictionary<TKey, TValue>: A sorted list of key/value pairs.

SortedList<TKey, TValue>: A sorted list of key/value pairs. Provides functionality similar to that found in the non-generic SortedList class.

SortedSet<T>: A sorted set.

Stack<T>: A first-in, last-out list. Provides functionality similar to that found in the non-generic Stack class.

Sudhir said:   10 years ago
What about stack?

Vijay Malviya said:   1 decade ago
using System;
using System.Collections.Generic;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{

SortedDictionary<string, int> obj = new SortedDictionary<string, int>();
obj.Add("Vijay", 1);
obj.Add("Ramesh", 2);
obj.Add("Raja", 3);

foreach (KeyValuePair<string, int> a in obj)
{
Console.WriteLine("{0},{1}", a.Key, a.Value);

}

Console.ReadLine();


}
}

}

Post your comments here:

Your comments will be displayed after verification.