Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mTable As New DataTable Dim mTable2 As New InheritedTable mTable.Columns.Add("Col1", System.Type.GetType("System.String")) mTable.Columns.Add("Col2", System.Type.GetType("System.String")) Dim Row As DataRow = mTable.NewRow Row(0) = "A" : Row(1) = "B" : mTable.Rows.Add(Row) Row = mTable.NewRow Row(0) = "C" : Row(1) = "D" : mTable.Rows.Add(Row) mTable2 = CType(mTable.Clone, InheritedTable).Copy 'THE ERROR OCCURS HERE End SubEnd Class Public Class InheritedTable Inherits System.Data.DataTable Private Sub DoSomething() 'Any code. End SubEnd Class
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mTable As New DataTable Dim mTable2 As New InheritedTable mTable.Columns.Add("Col1", System.Type.GetType("System.String")) mTable.Columns.Add("Col2", System.Type.GetType("System.String")) Dim Row As DataRow = mTable.NewRow Row(0) = "A" : Row(1) = "B" : mTable.Rows.Add(Row)
Row = mTable.NewRow Row(0) = "C" : Row(1) = "D" : mTable.Rows.Add(Row) mTable2 = CType(mTable.Clone, InheritedTable).Copy 'THE ERROR OCCURS HERE End Sub
End Class
Public Class InheritedTable Inherits System.Data.DataTable Private Sub DoSomething() 'Any code. End SubEnd Class
Attachment: QuestionCode.zip