User FAQs

If you have a question, please send it to us.


1) Can you give some examples of different types of Collections ?

System.Collections.ArrayList 
System.Collections.Generic.List
System.Collections.Generic.Dictionary
System.Collections.Generic.KeyValuePair

2) Can you create a list containing the values 1,2,3 using a generic collection class ?

System.Collections.Generic.List<int>MyList1; 
MyList1 = new System.Collections.Generics.List<int>();
MyList1.Add(1);
MyList1.Add(2);
MyList1.Add(3);

System.Collections.Generic.List<int>MyList2;
MyList2 = new System.Collections.Generics.List<int> {1, 2, 3};

3) Can you convert a generic list of integers to a string array ?
This can be converted using LINQ.

System.Collections.Generic.List<int>MyList1; 
string[] MyArray;
MyArray = MyList1.Select(i => i.ToString()).ToArray();

4) Write a method to return the length of a generic list without using the Count method or a For loop ?

int ListCount(System.Collections.Generic.List<string> MyList) 
{
   int itotal = 0;
   while (MyList.ElementAtOrDefault(itotal) != null)
   {
      itotal += 1;
   }
   return itotal;
}

5) What is a Hashtable ?
A hash table is a data structure that implements the IDictionary interface.
Is an example of a collection.
It is used to store multiple items and each one is associated with a unique key.
A hash table is an object that holds key-value pairs.


6) Why are there two kinds of SortedList ?
System.Collections.SortedList - was added in .NET 1.0
System.Collections.Generic.SortedList - was added in .NET 2.0


7) Can you explain what an iterator is as well as an iterator block ?




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext