Set - 10

Question 1 :

What's the difference between the System.Array.CopyTo() and System.Array.Clone()?

Answer :

The first one performs a deep copy of the array, the second one is shallow. A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to. In contrast, a deep copy of an Array copies the elements and everything directly or indirectly referenced by the elements.

Question 2 :

How can you sort the elements of the array in descending order?

Answer :

By calling Sort() and then Reverse() methods.

Question 3 :

What's the .NET collection class that allows an element to be accessed using a unique key?

Answer :


Question 4 :

What class is underneath the SortedList class?

Answer :

A sorted HashTable.

Question 5 :

Will the finally block get executed if an exception has not occurred?

Answer :