ToHashTable

        /// <summary>
        /// Converts a DataRow object into a Hashtable object, 
        /// where the key is the ColumnName and the value is the row value.
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        public static Hashtable ToHashTable(this DataRow dr)
        {
            Hashtable htReturn = new Hashtable(dr.ItemArray.Length);
            foreach (DataColumn dc in dr.Table.Columns)
                htReturn.Add(dc.ColumnName, dr[dc.ColumnName]);

            return htReturn;
        }
Example:
Hashtable ht = myDataRow.ToHashTable();

Description

Converts a DataRow into a Hashtable.

Details

Double click on the code to select all.

 

;