There is no specific method in the .NET Framework that allows only two specific elements to be swapped within an array. You can create a generic method to do so by using a temporary object to hold one of the items being swapped. Read the rest of this entry »
Popularity: 2% [?]
This article talks about storing the snapshot of data of current state in an array object. This can be applied to an ArrayList, Queue, Stack object, or any other datatype that implements the ICollection interface. This is done by using the CopyTo method declared in the ICollection interface. The following example, method TakeSnapshotOfList, accepts any type that implements the ICollection interface and takes a snapshot of the entire’s contents. This snapshot is returned as an object array. Read the rest of this entry »
Popularity: 2% [?]
This article talks about sorting keys and/or values contained in a Hashtable in order to display the entire Hashtable in either ascending or descending order.
The Hashtable object exposes two useful properties for obtaining a collection of its keys or values. The Keys property returns an ICollection containing all the keys currently in the Hashtable. The Values property returns the same for all values currently contained in the Hashtable. The two static methods below wraps the functionality by returning the ArrayList of objects containing the keys or values of a Hashtable. Read the rest of this entry »
Popularity: 4% [?]
In .NET Framework, the Array class provides a static Reverse method for reserving the order of elements within an array, or you can write your own method. For example an array as below:
int[] myArray = new int[5] {5, 6, 7, 8, 9, 10, 11};
You can use the status Reverse method in Array class, as in code: Read the rest of this entry »
Popularity: 2% [?]
.NET Framework provides a set of prebuilt collection classes in System.Collections. Among of these classes, I have been using ArrayList and Hashtable intensively. So far there is no problem in ArrayList class, but I ever encountered an exception “InvalidOperationException, Hashtable insert failed. Load factor too high” when trying to insert an item to the Hashtable collection. Read the rest of this entry »
Popularity: 4% [?]
You have a collection such as an ArrayList or a Hashtable in which you are storing application information. This information can be used to tailor the application’s environment to the last known settings (e.g., window size, window placement, currently displayed toolbars), or the information can be used to allow the user to start using the application at the same point where the application was last shut down. In other words, if the user were editing an invoice and needed to shut down the computer for the night, the application would know exactly which invoice to initially display when the application was started next time.
Read the rest of this entry »
Popularity: 2% [?]
In ArrayList class, it provides Insert and RemoveAt methods to insert and remove an item at a specific index, but this feature is not available in a standard array (System.Array). The following utility class provide two methods to do the job.
Popularity: 3% [?]
This article talks about creating a class that allows to set the minimum and/or maximum number of elements of Hashtable that it can hold. The MaxMinSizeHashtable class in the example will be inherited from Hashtable class. This class allows a definition of a maximum and a minimum size beyond which this MaxMinSizeHashtable cannot grow or shrink.
Read the rest of this entry »
Popularity: 2% [?]