DataTable table = new DataTable("Customers"); // Fill the table with data... foreach (DataRow row in table.Rows) { if (row["Country"].ToString() == "USA") { row.Delete(); } }
DataTable table = new DataTable("Customers"); // Fill the table with data... DataRow rowToDelete = table.Rows[3]; // get the 4th row (zero-based index) rowToDelete.Delete();This code deletes the 4th row from the `Customers` table. Package/Library: System.Data. In C#, the DataRow Delete method is part of the System.Data namespace which is included in the .NET Framework class library. This namespace provides classes that support ADO.NET architecture, including DataTable, DataRow, and DataSet. To use the DataRow Delete method, you need to add a reference to the System.Data.dll assembly.