C# Programming - Generics - Discussion

Discussion :: 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

[A]. 1 and 2 only
[B]. 2 and 4 only
[C]. 1 and 3 only
[D]. All of the above
[E]. None of the above

Answer: Option C

Explanation:

No answer description available for this question.

Vijay Malviya said: (Sep 20, 2011)  
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();


}
}

}

Sudhir said: (Oct 4, 2013)  
What about stack?

K2U2007 said: (Oct 3, 2014)  
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.

Ishwar Patil said: (Apr 27, 2016)  
Stack is non-generic.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.