DataTable's question in class ?

Please tell me why I received errors when doing this:

class MyClass : DataTable
{
public MyClass():base()
{
DataTable dt = new DataTable();
this = dt;// errors occur here, what can I do to let dt to "this"
}
}

Thank you for your help.



Answer this question

DataTable's question in class ?

  • eggie5

    I dont understand what you are trying to do.

    you cant reassign 'this'



  • Divya

    you cant reassign "this"

    if MyClass inherits DataTable

    this is already a DataTable, and Calling Base initializes it as a DataTable:

    class MyClass : DataTable
    {
    public MyClass():base()
    {
    Debug.Assert(this is DataTable);
    }
    }



  • SocratesBrighton

    class MyClass : DataTable
    {
    public MyClass():base()
    {
    mySqlDataAdapter = new SqlDataAdapter(command,connection);
    mySqlDataAdapter.Fill(
    this);
    /*
    How can I use myDataSet.Tables["myTable"] to let "this" like mySqlDataAdapter.Fill(this);
    For example :
    this = myDataSet.Tables["myTable"]; //errors occur here

    */

    }
    }

    Thank you.


  • DataTable's question in class ?