Hello Lucius,
According to your description, you need a method to copy the instance of
class which inherited from DataTable. Did I misunderstand anything here?
Please correct me. Thanks.
We need not override the base class's copy method, because the return type
of the new method is different from the DataTable.Copy method.
public DataTable Copy()
{....}
public table2 Copy()
{....}
What we need to do is to create a new method named Copy and return a
instance of class(inherited from DataTable). We could also get benefit from
base.Copy method. This method will copy all columns and rows from the
original instance. Then, we need set the other properties which we added
into the class, and then return new instance.
For example:
Table2 is a new class which inherited from datatable. I added id and name
as new properties.
class table2 : System.Data.DataTable
{
public int id;
public string name;
Implementation of Copy() method, calls base.Copy to copy all the columns
and rows and then set id and name.
public table2 Copy()
{
table2 t = new table2();
t = base.Copy() as table2;
t.id = this.id;
t.name = this.name;
return t;
}
}
Hope this helps.
Sincerely,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.