Is there a difference between DataTable.Clear and DataTable.Rows.Clear?

后端 未结 7 1572
天涯浪人
天涯浪人 2021-01-18 06:51

I recall there is a difference between some methods/properties called directly on the DataTable class, and the identically named methods/properties on the DataTable.Rows pro

7条回答
  •  终归单人心
    2021-01-18 07:31

    I've been testing the different methods now in .NET 1.1/VS2003, seems Matt Hamilton is right.

    • DataTable.Clear and DataTable.Rows.Clear seem to behave identical with respect to the two things I tested: both remove all rows (they don't mark them as deleted, they really remove them from the table), and neither removes the columns of the table.
    • DataTable.Reset clears rows and columns.
    • DataTable.Rows.Count does include deleted rows. (This might be 1.1 specific)
    • foreach iterates over deleted rows. (I'm pretty sure deleted rows are skipped in 2.0.)

提交回复
热议问题