



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




using System;
dataTable.Columns.Add(Email); //Setting the Primary Key dataTable.PrimaryKey = new DataColumn[] { Id }; //Add New DataRow by creating the DataRow object DataRow row1 = dataTable.NewRow(); row1["Id"] = 101; row1["Name"] = "Anurag"; row1["Email"] = "[email protected]"; dataTable.Rows.Add(row1); //Adding new DataRow by simply adding the values dataTable.Rows.Add(102, "Mohanty", "[email protected]"); foreach (DataRow row in dataTable.Rows) { Console.WriteLine(row["Id"] + ", " + row["Name"] + ", " + row["Email"]); } } catch (Exception e) { Console.WriteLine("OOPs, something went wrong.\n" + e); } Console.ReadKey(); } } }