Enables DataView to DataTable conversion

public static DataTable CreateTable(DataView obDataView)
    {
        if (null == obDataView)
        {
            throw new ArgumentNullException
            ("DataView", "Invalid DataView object specified");
        }

        DataTable obNewDt = obDataView.Table.Clone();
        int idx = 0;
        string[] strColNames = new string[obNewDt.Columns.Count];
        foreach (DataColumn col in obNewDt.Columns)
        {
            strColNames[idx++] = col.ColumnName;
        }

        IEnumerator viewEnumerator = obDataView.GetEnumerator();
        while (viewEnumerator.MoveNext())
        {
            DataRowView drv = (DataRowView)viewEnumerator.Current;
            DataRow dr = obNewDt.NewRow();
            try
            {
                foreach (string strName in strColNames)
                {
                    dr[strName] = drv[strName];
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            obNewDt.Rows.Add(dr);
        }

        return obNewDt;
    }
public static DataTable CreateTable(DataView obDataView)    {        if (null == obDataView)        {            throw new ArgumentNullException            ("DataView", "Invalid DataView object specified");        }         DataTable obNewDt = obDataView.Table.Clone();        int idx = 0;        string[] strColNames = new string[obNewDt.Columns.Count];        foreach (DataColumn col in obNewDt.Columns)        {            strColNames[idx++] = col.ColumnName;        }         IEnumerator viewEnumerator = obDataView.GetEnumerator();        while (viewEnumerator.MoveNext())        {            DataRowView drv = (DataRowView)viewEnumerator.Current;            DataRow dr = obNewDt.NewRow();            try            {                foreach (string strName in strColNames)                {                    dr[strName] = drv[strName];                }            }            catch (Exception ex)            {                Trace.WriteLine(ex.Message);            }            obNewDt.Rows.Add(dr);        }         return obNewDt;    }public static DataTable CreateTable(DataView obDataView)
    {
        if (null == obDataView)
        {
            throw new ArgumentNullException
            ("DataView", "Invalid DataView object specified");
        }

        DataTable obNewDt = obDataView.Table.Clone();
        int idx = 0;
        string[] strColNames = new string[obNewDt.Columns.Count];
        foreach (DataColumn col in obNewDt.Columns)
        {
            strColNames[idx++] = col.ColumnName;
        }

        IEnumerator viewEnumerator = obDataView.GetEnumerator();
        while (viewEnumerator.MoveNext())
        {
            DataRowView drv = (DataRowView)viewEnumerator.Current;
            DataRow dr = obNewDt.NewRow();
            try
            {
                foreach (string strName in strColNames)
                {
                    dr[strName] = drv[strName];
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            obNewDt.Rows.Add(dr);
        }

        return obNewDt;
    }

i write above in my program to convert dataview to data table, but their is an error shows that
"Using the Generic type 'System.Collection.Generic.IEnumerable<T>' required '1' type argument
please help me how i can solve this problem
thanks in advance

Edited 3 Years Ago by Nick Evan: Fixed formatting

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.